activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudi23 <rudi.stei...@gmail.com>
Subject Re: Best practice setting up Messageproducer/-consumer
Date Tue, 18 Dec 2007 14:04:22 GMT

Hello rajdavies,

thank you for the idea. Executing the setup in paralell threads will surely
reduce the startup time.

Rudi


rajdavies wrote:
> 
> 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.
>>
> 
> 
> 
> 
> 

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


Mime
View raw message