mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge pull request #51152 from MacAlsandair
Closes gh-51152 * docs-kafka-jackson-json-serde-4.0.x: Use JacksonJsonSerde in Kafka Streams documentation
This commit is contained in:
+2
-4
@@ -27,18 +27,16 @@ import org.apache.kafka.streams.kstream.Produced;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.kafka.annotation.EnableKafkaStreams;
|
||||
import org.springframework.kafka.support.serializer.JacksonJsonSerde;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableKafkaStreams
|
||||
public class MyKafkaStreamsConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public KStream<Integer, String> kStream(StreamsBuilder streamsBuilder) {
|
||||
KStream<Integer, String> stream = streamsBuilder.stream("ks1In");
|
||||
stream.map(this::uppercaseValue)
|
||||
.to("ks1Out",
|
||||
Produced.with(Serdes.Integer(), new org.springframework.kafka.support.serializer.JsonSerde<>()));
|
||||
stream.map(this::uppercaseValue).to("ks1Out", Produced.with(Serdes.Integer(), new JacksonJsonSerde<>()));
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -24,6 +24,7 @@ import org.apache.kafka.streams.kstream.Produced
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.kafka.annotation.EnableKafkaStreams
|
||||
import org.springframework.kafka.support.serializer.JacksonJsonSerde
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@@ -31,11 +32,9 @@ import org.springframework.kafka.annotation.EnableKafkaStreams
|
||||
class MyKafkaStreamsConfiguration {
|
||||
|
||||
@Bean
|
||||
@Suppress("DEPRECATION")
|
||||
fun kStream(streamsBuilder: StreamsBuilder): KStream<Int, String> {
|
||||
val stream = streamsBuilder.stream<Int, String>("ks1In")
|
||||
stream.map(this::uppercaseValue).to("ks1Out", Produced.with(Serdes.Integer(),
|
||||
org.springframework.kafka.support.serializer.JsonSerde()))
|
||||
stream.map(this::uppercaseValue).to("ks1Out", Produced.with(Serdes.Integer(), JacksonJsonSerde()))
|
||||
return stream
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user