Subscriber only service means an application which only consumes, does not produce.
We have generally seen the applications which both produces and consumes data from a Kafka topic but sometimes we need to write an application which only consumes data i.e. consumes data from a 3rd party service. So in this blog I am going to explain how to write a Lagom service which only consumes data (does not produce any data).
Add below dependency to your impl pom.xml:
We need to create a separate module kafka-connect in Lagom project. That module will contain a Service Descriptor declaring the topic service will consume from.
Then, add kafka-connect dependency in impl module:
Then, to consume data implement consumer as below:
Finally, you need to bind KafkaConsumer as Eager singleton and KafkaService in HelloModule:
To connect with external kafka, made below changes in root pom:
and, add below configuration in application.conf file:
That’s it. Now…
View original post 52 more words