-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow message handling of un-deserializable data
Co-authored-by: François Delbrayelle <fdelbrayelle@gmail.com>
- Loading branch information
1 parent
101f743
commit 9933831
Showing
15 changed files
with
224 additions
and
59 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
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
37 changes: 37 additions & 0 deletions
37
.../templates/src/main/java/package/service/kafka/deserializer/DeserializationError.java.ejs
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package <%= packageName %>.service.kafka.deserializer; | ||
|
||
public class DeserializationError { | ||
|
||
private byte[] data; | ||
|
||
private Exception exception; | ||
|
||
public DeserializationError(byte[] data, Exception exception) { | ||
this.data = data; | ||
this.exception = exception; | ||
} | ||
|
||
public byte[] getData() { | ||
return data; | ||
} | ||
|
||
public void setData(byte[] data) { | ||
this.data = data; | ||
} | ||
|
||
public Exception getException() { | ||
return exception; | ||
} | ||
|
||
public void setException(Exception exception) { | ||
this.exception = exception; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DeserializationError{" + | ||
"data='" + new String(data) + "'" + | ||
", exception=" + exception + | ||
'}'; | ||
} | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
test/templates/message-broker-with-entities-2nd-call/src/main/docker/akhq.yml
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '2' | ||
services: | ||
akhq: | ||
image: tchiotludo/akhq | ||
environment: | ||
AKHQ_CONFIGURATION: | | ||
akhq: | ||
connections: | ||
docker-kafka-server: | ||
properties: | ||
bootstrap.servers: "kafka:29092" | ||
ports: | ||
- 11817:8080 |
68 changes: 68 additions & 0 deletions
68
...oker-with-entities-2nd-call/src/main/java/com/mycompany/myapp/config/KafkaProperties.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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.mycompany.myapp.config; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerConfig; | ||
import org.apache.kafka.clients.producer.ProducerConfig; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "kafka") | ||
public class KafkaProperties { | ||
|
||
@Value("${kafka.bootstrap.servers:localhost:9092}") | ||
private String bootstrapServers; | ||
|
||
@Value("${kafka.polling.timeout:10000}") | ||
private Integer pollingTimeout; | ||
|
||
private Map<String, Map<String, Object>> consumer = new HashMap<>(); | ||
|
||
private Map<String, Map<String, Object>> producer = new HashMap<>(); | ||
|
||
@PostConstruct | ||
public void init() { | ||
|
||
for (String consumerKey: consumer.keySet()) { | ||
final Map<String, Object> properties = consumer.get(consumerKey); | ||
if (! properties.containsKey(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)) { | ||
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); | ||
} | ||
} | ||
|
||
for (String consumerKey: producer.keySet()) { | ||
final Map<String, Object> properties = producer.get(consumerKey); | ||
if (! properties.containsKey(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)) { | ||
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); | ||
} | ||
} | ||
} | ||
|
||
public Map<String, Map<String, Object>> getConsumer() { | ||
return this.consumer; | ||
} | ||
|
||
public void setConsumer(Map<String, Map<String, Object>> consumer) { | ||
this.consumer = consumer; | ||
} | ||
|
||
public Map<String, Map<String, Object>> getProducer() { | ||
return this.producer; | ||
} | ||
|
||
public void setProducer(Map<String, Map<String, Object>> producer) { | ||
this.producer = producer; | ||
} | ||
|
||
public Integer getPollingTimeout() { | ||
return pollingTimeout; | ||
} | ||
|
||
public void setPollingTimeout(Integer pollingTimeout) { | ||
this.pollingTimeout = pollingTimeout; | ||
} | ||
} |
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
Oops, something went wrong.