Java – Spring Integration and Spring Cloud Stream

Spring Integration and Spring Cloud Stream… here is a solution to the problem.

Spring Integration and Spring Cloud Stream

I’m writing an application

  • Polling the catalog (Sprint integration DSL process).
  • Once the file is available, it is put into the rabbitmq queue
  • The microservice listens to the stream RabbitMQ and processes the file (this is written by the Spring Cloud stream).

Now, I don’t know what is the best way to send messages from the Spring Integration streaming service to RabbitMQ. How to use spring-cloud stream in Spring-Integration to publish messages to RabbitMQ

Solution

You just need to implement a Source binding (bind) there and generate it from your source using RabbitMQ Binder. So the results of polling files from the directory will be published to Source.OUTPUT (or your custom binding (bind), and everything else will be done by RabbitMQ Binder: https://docs.spring.io/spring-cloud-stream/docs/Fishtown.M3/reference/htmlsingle/#spring-cloud-stream-overview-producing-consuming-messages

Of course, you can use AmqpOutboundEndpoint to perform a similar operation with normal Spring Integration to publish messages to the appropriate exchange on RabbitMQ: https://docs.spring.io/spring-integration/docs/5.0.8.RELEASE/reference/html/amqp.html#amqp-outbound-channel-adapter

Related Problems and Solutions