简体   繁体   English

spring-amqp一个队列多个侦听器

[英]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" 我有三个任务,这些任务将侦听单个队列“ replyQueue”上的所有答复

task1 
task2
task3

Each one is going to send one message on Rabbit and will wait for the response on the replyQueue 每个人都将在Rabbit上发送一条消息,并将等待replyQueue上的replyQueue

Task1 任务1

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

task2 任务2

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

task3 任务3

-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 但这将使我只能读取一个响应,但是我想为每个任务读取多个响应1

Please guide . 请指导。

Unless I am missing something in your question, you can simply do multiple receive() calls. 除非我在您的问题中遗漏了什么,否则您可以简单地执行多个receive()调用。

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. 如果这些任务同时运行,则不能使用相同的答复队列-否则这些任务将获得彼此的答复-在这种情况下,您需要为每个任务使用不同的答复队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM