activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jecsiac <jecs...@163.com>
Subject Re: Problem with Selector
Date Tue, 26 Aug 2008 13:08:58 GMT

>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 PDF
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 not
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 find
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 message
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' —— but should it include the time the provider needs to find 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.


Mime
View raw message