-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
42 additions
and
90 deletions.
There are no files selected for viewing
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
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
6 changes: 2 additions & 4 deletions
6
.../k8s-workshop-listener/src/main/java/com/maemresen/k8s/workshop/listener/ListenerApp.java
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
20 changes: 13 additions & 7 deletions
20
...tener/src/main/java/com/maemresen/k8s/workshop/listener/messaging/SensorDataConsumer.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package com.maemresen.k8s.workshop.listener.messaging; | ||
|
||
import com.maemresen.k8s.workshop.messaging.starter.BaseConsumer; | ||
import com.maemresen.k8s.workshop.messaging.starter.MessagingProps; | ||
import com.maemresen.k8s.workshop.messaging.starter.Topic; | ||
import com.maemresen.lib.message.dto.SensorData; | ||
import java.util.function.Consumer; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.stereotype.Component; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Component | ||
public class SensorDataConsumer implements Consumer<Message<SensorData>> { | ||
@Service | ||
public class SensorDataConsumer extends BaseConsumer<String, SensorData> { | ||
|
||
public SensorDataConsumer(final MessagingProps messagingProps) { | ||
super(Topic.SENSOR_DATA, messagingProps); | ||
} | ||
|
||
@Override | ||
public void accept(final Message<SensorData> message) { | ||
log.info("Received sensor data: {}", message); | ||
protected void processMessage(final ConsumerRecord<String, SensorData> consumerRecord) { | ||
log.info("Received sensor data with key {} and value {}", consumerRecord.key(), consumerRecord.value()); | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
...shop-listener/src/main/java/com/maemresen/k8s/workshop/listener/props/MessagingProps.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...p/k8s-workshop-listener/src/main/java/com/maemresen/k8s/workshop/listener/util/Topic.java
This file was deleted.
Oops, something went wrong.
37 changes: 15 additions & 22 deletions
37
module/app/k8s-workshop-listener/src/main/resources/application.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,23 @@ | ||
spring: | ||
profiles: | ||
active: dev | ||
cloud: | ||
stream: | ||
kafka: | ||
binder: | ||
brokers: localhost:9092 | ||
auto-add-partitions: true | ||
bindings: | ||
sensorDataConsumer-in-0: | ||
consumer: | ||
configuration: | ||
value.deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer | ||
schema.registry.url: http://localhost:8081 | ||
specific.avro.reader: true | ||
|
||
bindings: | ||
sensorDataConsumer-in-0: | ||
destination: ${app.messaging.topics.SENSOR_DATA.topic-name} | ||
group: sensor-data-listener | ||
kafka: | ||
bootstrap-servers: localhost:9092 | ||
consumer: | ||
group-id: group_id | ||
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer | ||
value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer | ||
properties: | ||
schema.registry.url: http://localhost:8081 | ||
specific.avro.reader: true | ||
producer: | ||
key-serializer: org.apache.kafka.common.serialization.StringSerializer | ||
value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer | ||
properties: | ||
schema.registry.url: http://localhost:8081 | ||
|
||
app: | ||
messaging: | ||
serializer: io.confluent.kafka.serializers.KafkaAvroSerializer | ||
scheme-registry-url: http://localhost:8081 | ||
topics: | ||
SENSOR_DATA: | ||
output-binding-name: sensorDataConsumer-in-0 | ||
topic-name: sensor-data | ||
name: sensor-data |
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