spring云数据流中的多输出绑定
我正在尝试设置多目标绑定,但由于某些原因,来自第二个通道的消息将发送到第一个spring云数据流中的多输出绑定,spring,spring-boot,spring-cloud,spring-cloud-dataflow,Spring,Spring Boot,Spring Cloud,Spring Cloud Dataflow,我正在尝试设置多目标绑定,但由于某些原因,来自第二个通道的消息将发送到第一个exchange.queue。例如: spring: cloud: stream: bindings: output: destination: exchange1 producer.requiredGroups: queue1 output-other: destination: excha
exchange.queue
。例如:
spring:
cloud:
stream:
bindings:
output:
destination: exchange1
producer.requiredGroups: queue1
output-other:
destination: exchange2
producer.requiredGroups: queue2
我还使用了org.springframework.cloud.stream.messaging.Source
作为默认输出,并为Output other
频道创建了专用的源绑定
public interface OtherSource {
String OUTPUT = "output-other";
@Output(OtherSource.OUTPUT)
MessageChannel output();
}
还有制片人阶级
@EnableBinding(Source.class)
public class OutputSender {
private final Source source;
public void send(Output1 obj) {
Message message = toMessage(obj);
this.source.output().send(message);
}
}
这正如预期的那样有效。消息被发送到正确的队列(exchange1.queue1
)
第二制作人:
@EnableBinding(OtherSource.class)
public class OutputOtherSender {
OtherSource source;
public void send(Output2 obj) {
Message message = toMessage(obj)
this.source.output().send(obj);
}
}
此设置有2个问题:
OtherSource
发送的消息将转到exchange1.queue1
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
org.springframework.boot
spring启动程序父级
2.1.6.1发布
org.springframework.cloud
春云流
2.2.0.1发布
org.springframework.cloud
春云溪
2.2.0.1发布
默认情况下,Spring Cloud数据流中的流应用程序是线性的,这意味着应用程序通过单输出->单输入相互绑定
如果您想让流使用多个输入/输出目的地,那么您必须手动配置绑定(使用Spring Cloud stream属性),并将应用程序定义为app
type-SCDF中流应用程序的特殊类型,允许用户手动配置绑定
有关这方面的更多信息,您可以参考: