Spring Cloud Stream 4.x metadatachannel

huangapple go评论49阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年3月9日 14:36:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75681179.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定