3
votes

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

1
I am not sure I fully understand. The stream service is bound to external destinations via binders. We currently provide both Rabbit and Kafka binders, so if you are using Rabbit binder then the output of your listener will automatically be published to Rabbit exchange. You don't have to do anything. - Oleg Zhurakousky
Thanks @OlegZhurakousky . Actually Artem has answered in detail I will try it. - Makky
Great! Perhaps semi-related, but should give you a bit more insight into stream lifecycle from the spring cloud stream perspective - docs.spring.io/spring-cloud-stream/docs/Fishtown.M3/reference/… - Oleg Zhurakousky

1 Answers

3
votes

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