spring.cloud.stream.source 的真正作用是什么?
What does the spring.cloud.stream.source really do?
我正在尝试了解 Spring Cloud Streams
的新功能模型如何工作以及配置在幕后如何实际工作。
我无法弄清楚的属性之一是 spring.cloud.stream.source
。
这个 属性 实际上意味着什么?
我无法理解 documentation :
Note that preceding example does not have any source functions defined
(e.g., Supplier bean) leaving the framework with no trigger to create
source bindings, which would be typical for cases where configuration
contains function beans. So to trigger the creation of source binding
we use spring.cloud.stream.source property where you can declare the
name of your sources. The provided name will be used as a trigger to
create a source binding.
如果我不需要 Supplier
怎么办?
源绑定到底是什么,它为什么重要?
如果我只想生成消息主题怎么办?我还需要这个 属性 吗?
我也无法理解示例中的用法 here。
Spring 云流查找 java.util
Function<?, ?
、Consumer<?>
、Supplier<?>
bean 并为它们创建绑定。
在供应商案例中,框架轮询供应商(默认情况下每秒一次)并发送结果数据。
例如
@Bean
public Supplier<String> output() {
return () -> "foo";
}
spring.cloud.stream.bindings.output-out-0.destination=bar
每秒将 foo
发送到目的地 bar
。
但是,如果您不需要轮询源,但您想要配置一个可以向其发送任意数据的绑定,该怎么办。输入 spring.cloud.stream.source
.
spring.cloud.stream.source=output
spring.cloud.stream.bindings.output-out-0.destination=bar
允许您向流桥发送任意数据
bridge.send("output-out-0", "test");
换句话说,它允许您配置一个或多个可以在 StreamBridge
中使用的输出绑定;否则,当您发送到网桥时,绑定是动态创建的。
我正在尝试了解 Spring Cloud Streams
的新功能模型如何工作以及配置在幕后如何实际工作。
我无法弄清楚的属性之一是 spring.cloud.stream.source
。
这个 属性 实际上意味着什么?
我无法理解 documentation :
Note that preceding example does not have any source functions defined (e.g., Supplier bean) leaving the framework with no trigger to create source bindings, which would be typical for cases where configuration contains function beans. So to trigger the creation of source binding we use spring.cloud.stream.source property where you can declare the name of your sources. The provided name will be used as a trigger to create a source binding.
如果我不需要 Supplier
怎么办?
源绑定到底是什么,它为什么重要?
如果我只想生成消息主题怎么办?我还需要这个 属性 吗?
我也无法理解示例中的用法 here。
Spring 云流查找 java.util
Function<?, ?
、Consumer<?>
、Supplier<?>
bean 并为它们创建绑定。
在供应商案例中,框架轮询供应商(默认情况下每秒一次)并发送结果数据。
例如
@Bean
public Supplier<String> output() {
return () -> "foo";
}
spring.cloud.stream.bindings.output-out-0.destination=bar
每秒将 foo
发送到目的地 bar
。
但是,如果您不需要轮询源,但您想要配置一个可以向其发送任意数据的绑定,该怎么办。输入 spring.cloud.stream.source
.
spring.cloud.stream.source=output
spring.cloud.stream.bindings.output-out-0.destination=bar
允许您向流桥发送任意数据
bridge.send("output-out-0", "test");
换句话说,它允许您配置一个或多个可以在 StreamBridge
中使用的输出绑定;否则,当您发送到网桥时,绑定是动态创建的。