【问题标题】:Spring Integration and Spring Cloud StreamSpring 集成和 Spring Cloud Stream
【发布时间】:2019-03-08 20:14:57
【问题描述】:

我正在编写一个应用程序

  • 轮询目录(Sprint 集成 DSL 流程)
  • 一旦文件可用,它将放入 rabbitmq 队列
  • 微服务监听流RabbitMQ并处理文件(这是写在Spring Cloud流中的)

现在,我无法弄清楚从 Spring Integration 流服务将消息发送到 RabbitMQ 的最佳方式是什么。如何在 Spring-Integration 中使用 spring-cloud 流将消息发布到 RabbitMQ

【问题讨论】:

  • 我不确定我是否完全理解。流服务通过活页夹绑定到外部目的地。我们目前提供 Rabbit 和 Kafka binders,因此如果您使用的是 Rabbit binders,那么侦听器的输出将自动发布到 Rabbit exchange。您无需执行任何操作。
  • 谢谢@OlegZhurakousky。其实Artem已经详细回答了我试试看。
  • 太棒了!也许是半相关的,但应该让您从 Spring Cloud Stream 的角度对流生命周期有更多的了解 - docs.spring.io/spring-cloud-stream/docs/Fishtown.M3/reference/…

标签: java spring rabbitmq spring-cloud-stream spring-integration-dsl


【解决方案1】:

您只需要在那里实现Source 绑定并使用RabbitMQ Binder 从您的源代码生成。因此,从目录轮询文件的结果将发布到Source.OUTPUT(或您的自定义绑定),其他一切都将由 RabbitMQ Binder 完成:https://docs.spring.io/spring-cloud-stream/docs/Fishtown.M3/reference/htmlsingle/#spring-cloud-stream-overview-producing-consuming-messages

当然,您可以使用 AmqpOutboundEndpoint 将消息发布到 RabbitMQ 上的适当交换:https://docs.spring.io/spring-integration/docs/5.0.8.RELEASE/reference/html/amqp.html#amqp-outbound-channel-adapter

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-27
  • 1970-01-01
  • 2018-10-22
  • 1970-01-01
  • 2019-10-24
相关资源
最近更新 更多