Search code examples
javaspringrabbitmqspring-cloud-streamspring-integration-dsl

Spring Integration and Spring Cloud Stream


I am writing an application that

  • Polls the directory (Sprint Integration DSL flow)
  • Once the file is available it will put in the rabbitmq queue
  • Microservice listen to the stream RabbitMQ and process the file (this is written in Spring Cloud stream)

Now, I cannot figure out what is the best way to send the message to the RabbitMQ from Spring Integration flow service. How can I use spring-cloud stream in the Spring-Integration to publish the message to the RabbitMQ


Solution

  • You just need to implement there a Source binding and use RabbitMQ Binder to produce from your source. So, the result of polling files from the directory is going to be published to the Source.OUTPUT (or your custom binding) and everything else will be done by the 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 do something similar with the plain Spring Integration using an AmqpOutboundEndpoint to publish a message to the appropriate exchange on the RabbitMQ: https://docs.spring.io/spring-integration/docs/5.0.8.RELEASE/reference/html/amqp.html#amqp-outbound-channel-adapter