Kafka has become a very popular platform and is being used as a stream, journal and even eventing system. In this post, we explore how to integrate Kafka with spring framework application. First, we add the Kafka bootstrap server details in the application.properties file.
Let's also add dependencies in pom.xml.
Now, for each Kafka topic, we create a listener class. The listener class provides a callback method that is called when any message is retrieved on that topic.
Now we create an endpoint through which we inject a message in the queue. The message is sent to the queue and is retrieved by the listener.
We autowire a KafkaTemplate instance that is used to send the message to the queue.
Let's also add dependencies in pom.xml.
Now, for each Kafka topic, we create a listener class. The listener class provides a callback method that is called when any message is retrieved on that topic.
Now we create an endpoint through which we inject a message in the queue. The message is sent to the queue and is retrieved by the listener.
We autowire a KafkaTemplate instance that is used to send the message to the queue.
$ curl -X POST \ > 'http://localhost:8081/send?token=3193fa24-a0ba-451b-83ff-eb563c3fd43b-cdf12811-7e41-474b-8fa6-e8fefd4a738c' \ > -H 'Content-Type: application/json' \ > -H 'Postman-Token: e281e3c5-0dae-4bb7-ac8d-6555f66a18c6' \ > -H 'cache-control: no-cache' \ > -H 'token: 3193fa24-a0ba-451b-83ff-eb563c3fd43b-cdf12811-7e41-474b-8fa6-e8fefd4a738c' \ > -d '{ > "message" : "This is my message!" > }' Message sent successfully!.The receipt of message is indicated in the spring server log.
2019-04-10 14:28:03.969 INFO 31091 --- [ntainer#0-0-C-1] i.s.b.t.listeners.MyTopicKafkaListener : Received Promise message This is my message!
People ought to by no means make compromises or lose small bets outcome of|as a outcome 1xbet of} they will obtain large things occasion that they} work collectively. As a outcome, people ought to begin small and progressively enhance their stakes. It’s a mistake to strive for larger prizes whereas ignoring smaller ones. In Punto Banco the participant can bet on their very own hand , the banker’s hand , or a tie.
ReplyDelete