- Open the message-service project from previous recipes. Modify the build.gradle file and add the spring-kafka project to the list of dependencies:
dependencies { compile group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.1.1.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-starter-web' testCompile group: 'junit', name: 'junit', version: '4.12'}
- The spring-kafka project provides a template for sending messages to a Kafka broker. To use the template in our project, we'll need to create a ProducerFactory interface and provide it to the constructor of the template.
- Open the Application.java file and add the following content. Note that we're hardcoding the network location of the Kafka ...