英文:
How to get correlation id in Spring Cloud Stream
问题
以下是翻译好的部分:
Spring团队,
下面的生产者可以成功地将值发送到Kafka主题。
@Bean
Supplier<Flux<Integer>> someProducer(){
return () -> Flux.range(1, 10);
}
但是...我们如何获取像使用ReactiveKafkaSender一样获取消息产生的关联ID?由于Flux是由Spring内部订阅的,是否有任何方法可以获取?
英文:
Spring Team,
The below producer is able to send the values to a kafka topic successfully.
@Bean
Supplier<Flux<Integer>> someProducer(){
return () -> Flux.range(1, 10);
}
But..how do we get the correlation id of the message produced as we get using ReactiveKafkaSender? Since the flux is subscribed by Spring internally, Is there any way to get?
答案1
得分: 1
Currently, the binder does not support getting the complete SenderResult
, only the RecordMetadata
of a successful send.
Please open a bug on GitHub (spring-cloud-stream
) and reference this question.
To get the RecordMetadata
you can use Supplier<Flux<Message<Integer>>>
and set the senderResult
header in the message to an AtomicInteger<Mono<RecordMetadata>>
; it will be populated with a Mono<RecordMeta> which you can subscribe to.
However, I can see that this is not much use without the correlation metadata.
英文:
Currently, the binder does not support getting the complete SenderResult
, only the RecordMetadata
of a successful send.
Please open a bug on GitHub (spring-cloud-stream
) and reference this question.
To get the RecordMetadata
you can use Supplier<Flux<Message<Integer>>>
and set the senderResult
header in the message to an AtomicInteger<Mono<RecordMetadata>>
; it will be populated with a Mono<RecordMeta> which you can subscribe to.
However, I can see that this is not much use without the correlation metadata.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论