Skip to content

KafkaProducer

seyyed edited this page Aug 7, 2021 · 2 revisions

this interface used for produce data to kafka and implement in kafka project

you must config the kafka project and add the project to your microservice and used this interface

Structure

methode

ProducerFactory<String, Object> producerFactory(Map<String, Object> configs)

configs that is custom config if you need

ProducerFactory for produceConfig

if you want set custom you must implement some key such as ProducerConfig.BOOTSTRAP_SERVERS_CONFIG , ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG and etc but some key is required to connect to kafka

void send(String topic, Object o)

topic of kafka that you must import it

o object that serialize and push it to kafka server

method call producer async and not return response

BaseDTO sendSynchronous(String topic, Object o);

topic of kafka that you must import it

o object that serialize and push it to kafka server

boolean response of call kafka server

you must know method not call server Async and it can delay for get response but you can manage result of kafka

void send(String topic, Object o, ProducerFactory<String, Object> config);

topic of kafka that you must import it

o object that serialize and push it to kafka server

config that is the kafka config for connect

method call producer async and not return response

BaseDTO sendSynchronous(String topic, String o, ProducerFactory<String, Object> config)

topic of kafka that you must import it

o object that serialize and push it to kafka server

config that is the kafka config for connect

boolean response of call kafka server

you must know method not call server Async and it can delay for get response but you can manage result of kafka

Clone this wiki locally