From: Gustavo Martin Morcuende Date: Sun, 29 Jan 2017 18:55:59 +0000 (+0100) Subject: Required default constructor for Jackson deserialization. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=f886be669fdd50d6fe9643a817d23fc900307a4c;p=JavaForFun Required default constructor for Jackson deserialization. --- diff --git a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/MyCustomMessageConverter.java b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/MyCustomMessageConverter.java index f489302..419ae06 100644 --- a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/MyCustomMessageConverter.java +++ b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/MyCustomMessageConverter.java @@ -1,7 +1,5 @@ package de.example.spring.kafka; -import java.nio.charset.Charset; - import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.util.MimeType; diff --git a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/Product.java b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/Product.java index 98564a5..6053200 100644 --- a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/Product.java +++ b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-common-example/src/main/java/de/example/spring/kafka/Product.java @@ -4,6 +4,13 @@ public class Product { private String name; private String description; + /** + * Required for deserialization from Jackson. + */ + protected Product() { + + } + public Product(String name, String description) { this.name = name; this.description = description; diff --git a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-consumer-example/src/main/resources/application.yml b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-consumer-example/src/main/resources/application.yml index 72eafba..f4f8991 100644 --- a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-consumer-example/src/main/resources/application.yml +++ b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-consumer-example/src/main/resources/application.yml @@ -11,6 +11,8 @@ kafka: spring: main: banner-mode: "off" + # We do not need Tomcat running (this application runs from console) + web-environment: false cloud: stream: bindings: @@ -19,6 +21,7 @@ spring: destination: test group: helloworld contentType: application/json + startOffset: latest consumer: concurrency: 1 partitioned: false diff --git a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-producer-example/src/main/resources/application.yml b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-producer-example/src/main/resources/application.yml index 07b1ebf..eff109c 100644 --- a/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-producer-example/src/main/resources/application.yml +++ b/SpringJava/Kafka/SpringCloudStream/spring-cloud-stream-kafka-producer-example/src/main/resources/application.yml @@ -7,7 +7,7 @@ logging: spring: main: banner-mode: "off" - # We do not need Tomcat running (this application runs as a client) + # We do not need Tomcat running (this application runs from console) web-environment: false cloud: stream: @@ -15,10 +15,10 @@ spring: output: binder: kafka destination: test + # Requires work around, see: MyCustomMessageConverter contentType: application/json - # headerMode value is used only when input bindings :( - # headerMode: raw - #contentType: "application/example" + # Consumer (input) and producer (output) are Spring Cloud Stream applications :) + headerMode: embeddedHeaders instanceCount: 1 instanceIndex: 0 kafka: