简体   繁体   English

如何在字符串云 Stream 功能 Model (v3.1+) 中创建生产者?

[英]How to create producer in String Cloud Stream Functional Model (v3.1+)?

How can I create producer in Spring Cloud Stream Functional Model?如何在 Spring 云 Stream 功能 Model 中创建生产者?
The following version is deprecated now.以下版本现已弃用。

@Output(OUTPUT)
MessageChannel outbound();

I know that it is possible to achieve by java Supplier functional class, but it will send message every one second.我知道可以通过 java Supplier功能 class 来实现,但它会每隔一秒发送一次消息。 I don't need it to send every second.我不需要它每秒发送一次。 I am going to replace REST API with with Kafka.我将用 Kafka 替换 REST API。

Are there any ways to do that?有没有办法做到这一点?

Use the StreamBridge - see Sending data to an arbitrary output .使用StreamBridge - 请参阅将数据发送到任意 output

Here we autowire a StreamBridge bean which allows us to send data to an output binding effectively bridging non-stream application with spring-cloud-stream .在这里,我们自动装配一个StreamBridge bean,它允许我们将数据发送到 output 绑定,有效地将非流应用程序与spring-cloud-stream桥接。 Note that preceding example does not have any source functions defined (eg, Supplier bean) leaving the framework with no trigger to create source bindings, which would be typical for cases where configuration contains function beans.请注意,前面的示例没有定义任何源函数(例如, Supplier bean),使框架没有创建源绑定的触发器,这对于配置包含 function bean 的情况很典型。 So to trigger the creation of source binding we use spring.cloud.stream.source property where you can declare the name of your sources.因此,为了触发源绑定的创建,我们使用spring.cloud.stream.source属性,您可以在其中声明源的名称。

If you want to trigger a stream from an external Kafka topic, you can also bind a spring cloud steam processor's input to that topic.如果您想从外部 Kafka 主题触发 stream,您还可以将 spring 云蒸汽处理器的输入绑定到该主题。 The stream bridge provides a layer of abstraction that may be cleaner, Ie, your non-stream application does not use the Kafka API directly. stream 桥提供了一个可能更干净的抽象层,即您的非流应用程序不直接使用 Kafka API。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Spring Cloud Kafka Stream 3.1 创建生产者 - How can create a producer using Spring Cloud Kafka Stream 3.1 Spring 云 stream 功能性生产者/消费者 bean 在 @SpringBootApplication 之外声明时不起作用 - Spring cloud stream functional producer/consumer bean is not working when declared out side of @SpringBootApplication Spring Cloud Stream Kafka生产者消息 - Spring Cloud Stream Kafka Producer messages 使用 StreamBridge 在 Spring Cloud Stream 中的生产者回调 - Producer callback in Spring Cloud Stream using StreamBridge 如何迁移到函数式编程模型以在 Spring Cloud 中发布到 Kafka - How to move to functional programming model to publish to Kafka in Spring cloud Spring 云 Stream - 功能供应商未轮询 - Spring Cloud Stream - Functional Supplier is not polling 如何将 Spring Cloud Stream Functional Beans 连接到 Kafka Binder? - How do I Connect Spring Cloud Stream Functional Beans to a Kafka Binder? 使用 Cloud Stream Binder 处理 Springboot Kafka Producer 错误 - Springboot Kafka Producer Error Handling with Cloud Stream Binder 如何使用 spring-cloud-stream-binder-kafka-streams:3.1.1 中的功能方法检索/设置 header - How to retrieve/set header using functional approach in spring-cloud-stream-binder-kafka-streams:3.1.1 如何在 Spring Cloud Stream 中同时具有消费者和生产者事务的应用程序中设置事务 ID 前缀 - How to set transaction-id-prefix in app which has both consumer and producer-only transactions in Spring Cloud Stream
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM