The creation of a consumer and producer results in a round trip to the broker - and as you are doing this sequentially. Why not simply initialize each producer/consumer pair in a separate thread?

On Dec 17, 2007, at 8:52 AM, Rudi23 wrote:


Hello,

I have about 300 queues which hold a number. This number I have to update every 5 seconds and to delete the old numbner, if the consumer of this queue has not picked up the message. So at startup I initialize a MessageProducer and a MessageConsumer for each queue and hold this instances in a HashMap to
use them later:

private Map<String, MessageConsumer> consumers;
private Map<String, MessageProducer> producers;

for (String id : machIdList) {

                                logger.debug("Initializing queue: " + id);

                                Destination destination = 
session.createQueue(id);
                                MessageProducer producer = 
session.createProducer(destination);
                                MessageConsumer consumer = 
session.createConsumer(destination);

                                
producer.setTimeToLive(Settings.MESSAGE_TIME_TO_LIVE);

                                producers.put(id, producer);
                                consumers.put(id, consumer);
                        }

This works fine as soon as the producer and consumers have been set up.
Updating all 300 queues takes about 300 ms, which is ok in my case.

The problem is, that the loop for the initialization of the producers and consumers is slow. It takes about 300 ms for each queue which in sum is a
lot of time.

Could anyone please tell me if my approach is ok and if so, can I make it
faster. Or is there a best practice for this problem?

Thank you in advance,
Rudi
--
View this message in context: 
http://www.nabble.com/Best-practice-setting-up-Messageproducer--consumer-tp14370158s2354p14370158.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.




Reply via email to