How to limit message listener of a particular instance

9/4/2019

I have an app which is having two queues SOURCE and SINK(Rabbitmq queues) added as a part of Spring Cloud stream.

Now the app makes a payment and does a reconciliation process. Both are async operations.

I have a use case where I need to send a report based on reconciliation and payment results.

Now consider I have 2 instances of the same app running, so now I have 2 listeners for the SINK queue.

Now the issue is, the payment is happening on one instance and a message is being sent to SINK, so the other part(reconciliation) is done on another instance, due to this phenomenon I am not able to collect both the reports and send it to the user.

Is there any way to control this behavior, I want the same app to send a message and listen to the same message and do the reconciliation part, for every request I want only one instance to do ALL the job?

Is there any way we can do this using Spring Cloud Stream?

-- Debashis
kubernetes
rabbitmq
spring-boot
spring-cloud-stream

0 Answers