Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 52678 invoked from network); 26 Aug 2008 13:13:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Aug 2008 13:13:41 -0000 Received: (qmail 67524 invoked by uid 500); 26 Aug 2008 13:13:39 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 67137 invoked by uid 500); 26 Aug 2008 13:13:38 -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 67126 invoked by uid 99); 26 Aug 2008 13:13:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2008 06:13:38 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of james.strachan@gmail.com designates 64.233.184.232 as permitted sender) Received: from [64.233.184.232] (HELO wr-out-0506.google.com) (64.233.184.232) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2008 13:12:39 +0000 Received: by wr-out-0506.google.com with SMTP id 50so1861223wri.2 for ; Tue, 26 Aug 2008 06:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=auR3JVI6NHIfIUwR4hFlRBZZGRf6tLDwZ624NM0+B78=; b=gyzFnMHpQH+eJ8m09mTFQk/Yz7N+OwNGN/J3Ezl9x+ss1vp0lHwecj8Dgd17MlgRTf cpNXJX+x0QCBvVyt43LhJlbtK9jwODUXVb4xFPgPSZrXYHOVhOmbIxjB2/rf1SQPzZeu C3bAZ8R+IMPbSfan4Vk9wEd/xE1pU911vQku8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gJwrOua/OhVczSSMJAgcuhGDJsiaiO6EbyH1p2KFWTDX6TxT7WiS2+pLGQDyYSwoJ+ JJ11C8yg5igcQSyKk4encvG0j+rHRhNve9uqG/9GjZpmyc1cR/BDMYaLkNTjbDav9jbi upZvJHL7vBYg2Y4rbWDDpozgivyXu1CWKhYs4= Received: by 10.90.29.13 with SMTP id c13mr7108350agc.32.1219756388463; Tue, 26 Aug 2008 06:13:08 -0700 (PDT) Received: by 10.90.117.12 with HTTP; Tue, 26 Aug 2008 06:13:08 -0700 (PDT) Message-ID: Date: Tue, 26 Aug 2008 14:13:08 +0100 From: "James Strachan" To: users@activemq.apache.org Subject: Re: Problem with Selector In-Reply-To: <19161717.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <19157015.post@talk.nabble.com> <19161717.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org It seems to be provider specific. Many JMS providers will treat "Receives the next message if one is immediately available" literally - i.e. not to wait for a request/response with the broker to check if there is a message available for processing. This is what ActiveMQ does and a number of other JMS providers do the same - but its provider specific. At the very least you should wait some period of time (say 1 second) after creating your consumer before issuing a receiveNoWait() if you want your code to work with most JMS providers - or use receive(1000) on the first call - then use receiveNoWait() afterwards etc. 2008/8/26 Jecsiac : > >>receiveNoWait() is not meant to wait for a message to arrive. In >>ActiveMQ creating a receiver does not block until messages are >>received. > >>i.e. its not really JMS compliant to use receiveNoWait() and not >>expect nulls to come back if you've not really left much time for the >>JMS provider to actually find the messages and return them over the > > JMS 1.1 Specification has no words on receiveNoWait() (at least in it's P= DF > document). And in JMS 1.1 API document, it just said: > > receiveNoWait > public Message receiveNoWait() > throws JMSException > Receives the next message if one is immediately available. > Returns: > the next message produced for this message consumer, or null if one is no= t > available > Throws: > JMSException - if the JMS provider fails to receive the next message due = to > some internal error. > > Maybe it is some amphibolous. So I think my expectation could also be > proper: There're 2000 messages in the queue, and the message I want to fi= nd > is just in them, so why receiveNoWait() gives me a null? Of course, the > provider needs time to find out the message. But in contrast with receive= (): > > receive > public Message receive() > throws JMSException > Receives the next message produced for this message consumer. > This call blocks indefinitely until a message is produced or until this > message consumer is closed. > > If this receive is done within a transaction, the consumer retains the > message until the transaction commits. > > Returns: > the next message produced for this message consumer, or null if this mess= age > consumer is concurrently closed > Throws: > JMSException - if the JMS provider fails to receive the next message due = to > some internal error. > > It seems NoWait could means no 'blocks indefinitely until a message is > produced' =97=97 but should it include the time the provider needs to fin= d out > the message? No more words. So maybe it is some amphibolous. > > -- > View this message in context: http://www.nabble.com/Problem-with-Selector= -tp19157015p19161717.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > > --=20 James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com