This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka.controller; | |
import lombok.RequiredArgsConstructor; | |
import org.apache.kafka.clients.consumer.ConsumerRecord; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.kafka.annotation.KafkaListener; | |
import org.springframework.messaging.handler.annotation.Payload; | |
import org.springframework.web.bind.annotation.RestController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka.config; | |
import com.medium.kafka.ConsumerApplicationProperties; | |
import lombok.RequiredArgsConstructor; | |
import org.apache.kafka.clients.admin.NewTopic; | |
import org.apache.kafka.common.serialization.StringDeserializer; | |
import org.springframework.boot.autoconfigure.kafka.KafkaProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
kafka: | |
consumer: | |
# Specifies the name of the consumer group a Kafka consumer belongs to | |
group-id: topic-loggers | |
# Kafka server location. By accessing the localhost, we're acessing the | |
# kafka within the docker container running on port 9002 | |
bootstrap-servers: localhost:9092 | |
server: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka.controller; | |
import com.medium.kafka.ProducerApplicationProperties; | |
import lombok.RequiredArgsConstructor; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.kafka.core.KafkaTemplate; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka.controller; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import lombok.Data; | |
@Data | |
public class CachedEntity { | |
private int entityId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka.config; | |
import com.medium.kafka.ProducerApplicationProperties; | |
import lombok.RequiredArgsConstructor; | |
import org.apache.kafka.clients.admin.NewTopic; | |
import org.apache.kafka.clients.producer.ProducerConfig; | |
import org.apache.kafka.common.serialization.ByteArrayDeserializer; | |
import org.apache.kafka.common.serialization.StringDeserializer; | |
import org.apache.kafka.common.serialization.StringSerializer; | |
import org.springframework.boot.autoconfigure.kafka.KafkaProperties; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.medium.kafka; | |
import lombok.Data; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
import org.springframework.context.annotation.Configuration; | |
@Data | |
@Configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'org.springframework.boot' version '2.4.4' | |
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | |
id 'java' | |
} | |
group = 'com.medium.kafka' | |
version = '0.0.1-SNAPSHOT' | |
sourceCompatibility = '11' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
kafka: | |
# Kafka server location. By accessing the localhost, we're acessing the | |
# kafka within the docker container running on port 9002 | |
bootstrap-servers: localhost:9092 | |
server: | |
#Port where our producer application will be running | |
port: 8002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose run |
NewerOlder