简体   繁体   中英

RabbitMQ RPC producer with Multithreading

How can i implement a RPC call in multithread environnement? In the basic tutorial here: https://www.rabbitmq.com/tutorials/tutorial-six-java.html , in multithread environnement, I see two problems:

-If all is in different thread (including constructor), we create a reply queue for each thread, i don't thing it is a good idea (no ?)

-If only fibonacciRpc.call("4") is in different thread, the consumer for the reply queue can consume the bad reply, and the original consumer for this reply will wait indefinitely.

I did not found any solution for now but maybe a I did not understand something.

In my case : channel.basicConsume(replyQueueName, true, new DefaultConsumer(channel) {} is causing alot of heap size in memory and it does not gets cleared as long as i do not delete channel.

As per Internet , you are supposed to create one connection. create channel per thread and create separate queue per channel and delete queue after you read the response , if you do not it will keep creating new queue over and over, in the same channel.

But new DefaultConsumer is creating alot of heap memory.

Looks like to get rid of this I have to delete channel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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