簡體   English   中英

如何使用 Spring Cloud Kafka Stream 3.1 創建生產者

[英]How can create a producer using Spring Cloud Kafka Stream 3.1

我知道如何使用命令式編程方法定義生產者,但我找不到如何使用函數式編程方法定義生產者。

我閱讀了 Spring Cloud Stream Binder 文檔,但只找到了如何定義消費者或消費者和生產者(例如,從主題獲取信息,轉換數據並發送到另一個主題)。

所以,我不知道是否可以繼續使用@Input@Ouptut類的注釋來定義單個處理器,此時我很困惑,因為庫表明這些注釋已被棄用,但我找不到示例或文檔來定義一個簡單的生產者以將信息發送到特定主題。

謝謝!

文檔鏈接: https://docs.spring.io/spring-cloud-stream-binder-kafka/docs/3.0.10.RELEASE/reference/html/spring-cloud-stream-binder-kafka.html#_kafka_stream

您可以定義一個Supplier<?> @Bean ,它將按時間間隔輪詢以生成 output (如@InboundChannelAdapter通道的@Output

https://docs.spring.io/spring-cloud-stream/docs/3.1.0/reference/html/spring-cloud-stream.html#spring_cloud_function

或者,您可以使用StreamBridge將任意消息發送到 output 目標。

https://docs.spring.io/spring-cloud-stream/docs/3.1.0/reference/html/spring-cloud-stream.html#_sending_arbitrary_data_to_an_output_e_g_foreign_event_driven_source

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM