Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 64301 invoked from network); 15 Feb 2009 00:10:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2009 00:10:44 -0000 Received: (qmail 85624 invoked by uid 500); 15 Feb 2009 00:10:43 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 85600 invoked by uid 500); 15 Feb 2009 00:10:43 -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 85589 invoked by uid 99); 15 Feb 2009 00:10:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2009 16:10:43 -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 (nike.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; Sun, 15 Feb 2009 00:10:34 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1LYUaL-0001Km-5x for users@activemq.apache.org; Sat, 14 Feb 2009 16:10:13 -0800 Message-ID: <22018602.post@talk.nabble.com> Date: Sat, 14 Feb 2009 16:10:13 -0800 (PST) From: hackingbear To: users@activemq.apache.org Subject: Prefetch=0 how to? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: hackingbear@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have two server components in my system. A gateway server and multiple application server. The gateway server communicates with external system and does the following: 1. receive tokens from the external system and place them in a queue (the token queue.) 2. receive business requests from application servers and send them to the external system My application servers essentially do the following: 1. receive some user messages from somewhere 2. get a token from the token queue (by calling consumer.receive()) 3. create and send a business request message from the token (and other data) The problem is that the tokens are expensive, costing money literally, and so there are maybe only a few available at a time. Now, for example, the gateway sends out two (and only two) tokens A and B; there are two application servers running, each having a consumer on the token queue. Server 2 is idle while Server 1 receives two user messages. - Server 1 receives user message 1, and so try to get a token, get token A and send out the business request. Everything is fine so far. - Server 1 receives user message 2, and so try to get a token, get token B, but get stuck. What happen? Token B gets pre-fetched to Server 2's consumer even though that server never actually need it. I have set the prefetch to 1. Following http://activemq.apache.org/what-is-the-prefetch-limit-for.html, I then attempt to create the consumer with prefetch=0 queue = new ActiveMQQueue("TOKEN.QUEUE?consumer.prefetchSize=0"); consumer = session.createConsumer(queue); However, the effect is identical to prefetch=1: token B still get pre-fetched to Server 2. now, my solution is to write an async consumer which will, upon receiving a token, check if there is any local request pending, if not, send it back to the queue. the downside is, of course, the consumer would loop and resending the tokens forever even if the servers are idle. Any better solution? Thanks -- View this message in context: http://www.nabble.com/Prefetch%3D0-how-to--tp22018602p22018602.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.