3

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

muttonUp
  • 6,351
  • 2
  • 42
  • 54
Makky
  • 17,117
  • 17
  • 63
  • 86
  • 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 Oct 03 '18 at 15:23
  • Thanks @OlegZhurakousky . Actually Artem has answered in detail I will try it. – Makky Oct 03 '18 at 15:28
  • 1
    Great! Perhaps semi-related, but should give you a bit more insight into stream lifecycle from the spring cloud stream perspective - https://docs.spring.io/spring-cloud-stream/docs/Fishtown.M3/reference/htmlsingle/#_binding_visualization_and_control – Oleg Zhurakousky Oct 03 '18 at 15:35

1 Answers1

3

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

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • 1
    Do you have any sample for this in github? I am very new to Spring Integration and spring Cloud stream. – Makky Oct 03 '18 at 15:24
  • 1
    Take a look here: https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/source-samples. The JDBC sample should fit your expectations. Only what you need is to change it for files polling. – Artem Bilan Oct 03 '18 at 15:28
  • 1
    You are awesome sir. That will help me. You are genius. Thanks a lot. – Makky Oct 03 '18 at 15:30
  • if you have some time please can you answer https://stackoverflow.com/questions/52644505/rabbitmq-alternative-for-local – Makky Oct 04 '18 at 10:54