Producers
Producer classes help in pushing data from the application to kafka topics. For this, we have a custom implementation of KafkaTemplate class in our tracer library called CustomKafkaTemplate. This implementation of producer class does not change across services of DIGIT. Producer implementation can be viewed here - Producer Implementation
Now, for adding producer support in this guide, the following steps need to be followed -
i) Update tracer version in pom.xml to 2.0.0-SNAPSHOT
ii) Create a producer
folder and add a new class to it by the name of Producer
. Add the following code the this class -
@Service
@Slf4j
public class Producer {
@Autowired
private CustomKafkaTemplate<String, Object> kafkaTemplate;
public void push(String topic, Object value) {
kafkaTemplate.send(topic, value);
}
}