activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudi23 <>
Subject Best practice setting up Messageproducer/-consumer
Date Mon, 17 Dec 2007 08:52:09 GMT


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);


				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,
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message