Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 17787 invoked from network); 17 Dec 2007 08:52:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Dec 2007 08:52:41 -0000 Received: (qmail 61326 invoked by uid 500); 17 Dec 2007 08:52:29 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 61301 invoked by uid 500); 17 Dec 2007 08:52:29 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 61290 invoked by uid 99); 17 Dec 2007 08:52:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2007 00:52:29 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2007 08:52:06 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1J4Bhp-0008UH-O4 for users@activemq.apache.org; Mon, 17 Dec 2007 00:52:09 -0800 Message-ID: <14370158.post@talk.nabble.com> Date: Mon, 17 Dec 2007 00:52:09 -0800 (PST) From: Rudi23 To: users@activemq.apache.org Subject: Best practice setting up Messageproducer/-consumer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: rudi.steiner@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org 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 consumers; private Map 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.