Pushparaj Dhole
Pushparaj Dhole

Reputation: 63

spring-amqp one queue multiple listeners

How can I configure the receiver for following requirement

I have three tasks which will listen all the replies on single queue "replyQueue"

task1 
task2
task3

Each one is going to send one message on Rabbit and will wait for the response on the replyQueue

Task1

     -send message 
        -wait for the responses 
        -There can be multiple responses 
                -status message 1
                -status message 2
                -final message

task2

-send message 
    -wait for the responses 
    -There can be multiple responses 
            -status message 1
            -status message 2
            -final message

task3

-send message 
    -wait for the responses 
    -There can be multiple responses 
            -status message 1
            -status message 2
            -final message

Now I have to do different tasks depending upon the response. How i can configure my queues and listeners?

I tried with following

template.send("TaskQueue",message);
Message response= template.receive("replyQueue");

but this will allow me to read only one response but i want to read multiple response for each task1

Please guide .

Upvotes: 0

Views: 1311

Answers (1)

Gary Russell
Gary Russell

Reputation: 174574

Unless I am missing something in your question, you can simply do multiple receive() calls.

You can't use the same reply queue if these tasks run concurrently - otherwise the tasks will get each other's replies - in that case you need a different reply queue for each.

Upvotes: 0

Related Questions