英文:
Spring cloud stream 4.x metadatachannel
问题
metadata channel is not available in 4.x
Spring cloud stream : 4.0.1
binder type : Kafka
英文:
want to get the output channel name after message is published to the destination.
metadata channel is not available in 4.x
spring.cloud.stream.kafka.bindings.myBinding.producer.**record-metadata-channel**
Spring cloud stream : 4.0.1
binder type : Kafka
答案1
得分: 1
This works for me with version 4.0.1
. When the supplier is invoked and the message is published to the Kafka topic, the handler method on the record metadata channel is called. I can see the sent message in the output. What is not working in your application?
英文:
This works for me with version 4.0.1
. When the supplier is invoked and the message is published to the Kafka topic, the handler method on the record metadata channel is called. I can see the sent message in the output. What is not working in your application?
@SpringBootApplication
public class So75681179Application {
public static void main(String[] args) {
SpringApplication.run(So75681179Application.class, args);
}
@Bean
public Supplier<Message<String>> supplier() {
return () -> MessageBuilder.withPayload("foo").setHeader(KafkaHeaders.KEY, "my-foo".getBytes(StandardCharsets.UTF_8)).build();
}
@Bean
public MessageChannel fooRecordChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow integrationFlow() {
return f -> f.channel("fooRecordChannel")
.handle((payload, messageHeaders) -> {
System.out.println("Sent message: " + new String((byte[]) payload));
return payload;
});
}
}
and the configuration:
spring:
cloud:
function:
definition: supplier
stream:
kafka:
bindings:
supplier-out-0:
producer:
recordMetadataChannel: fooRecordChannel
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论