There's not heaps to go on so a few questions. Which version are you
using? Do you create the consumers up front and reuse them for each
request? Is there a time lag between sending a message and calling
receiveNoWait()?
Note that in ActiveMQ receiveNoWait() really and truly is that - we
don't wait a single millisecond or request-response communication with
the broker - if there is a message available it is returned without
any delay.
Some JMS providers interpret receiveNoWait() as a 'poll the broker and
see if there is a message available and if so fetch it'. FWIW now we
have support for pull based consumption we could consider adding this
feature as an option if people want it - I suspect that might be the
behaviour you are expecting.
As a workaround try using a timeout of 1000 or something?
On 8/18/06, peter anderson <[EMAIL PROTECTED]> wrote:
Hi,
I am evaluating ActiveMQ against Joram as my companies JMS provider.
I am using a producer servlet to produce a 1000 object messages and using a
consuming servlet to consume the messages (SEE CODE BELOW).
The problem is the messages are NOT being found. If I run it through debugger in
Eclipse it works as expected. This suggests it is a timing issue. Is this
correct and if so how may milliseconds should be used with the receive()
method ?
p.s. it works fine in Joram.
TIA Peter
/*
* Consume messages until no more are found.
*/
ObjectMessage message ;
while ( true )
{
Message m = consumer.receiveNoWait() ;
if ( m instanceof ObjectMessage )
{
message = (ObjectMessage) m ;
out.println( "Reading message: " + ( (InvBean)
message.getObject()
).toString() + "<br />" ) ;
}
else if ( m instanceof TextMessage )
{
out.println( "Reading TEXT message: " + (
(TextMessage) m ).getText() +
"<br />" ) ;
}
else
{
break ;
}
}
}
--
James
-------
http://radio.weblogs.com/0112098/