activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <>
Subject Re: NPE- Consumer Example
Date Sat, 28 Nov 2009 17:53:36 GMT
On Fri, Nov 27, 2009 at 7:39 PM, Uday Subbarayan
<> wrote:
> Thanks Bruce. My config is like yours and /etc/hosts also fine. I am now writing my own
consumer and having some problem....i get "null" message.
> My producer is http post, admin page correctly shows the message but having problem with
consumer. I am looking in to it right now.

Two things:

1) What are the steps you're using the to run the examples? Below are
the steps I use:

a) In terminal one, start up ActiveMQ (where $ACTIVEMQ_HOME is equal
to the directory in which ActiveMQ is installed):

$ ./bin/activemq

b) In terminal two, run the producer using the following commands:

$ cd $ACTIVEMQ_HOME/example
$ ant producer -Dsubject=myqueue

c) In terminal two, after the producer finishes, run the consumer
using the following command:

$ ant consumer -Dsubject=myqueue

These steps yield the proper behavior of both ActiveMQ and the
producer/consumer example.

2) Anytime I encounter folks who need to write their own JMS clients,
I always encourage them to first look at the Spring JMS APIs. For JMS
message consumers, I suggest starting with the Spring

The DefaultMessageListenerContainer (DMLC) provides the ability to set
a range of concurrent consumers, various tiered caching levels
(connection, session, consumer), it works with transactions and much
more. The reason I recommend the DMLC (or one of the other message
listener containers) is because writing JMS clients is a lot of work
and the Spring message listener containers dramatically reduce the
complexity thereby saving you quite a lot of time. Given the
tremendous flexibility, the robustness, the high amount of
configurability and the widespread deployment in businesses all over
the world (including in the financial markets), there really is no
reason not to use it.

Additionally, the combination of the Spring CachingConnectionFactory
and the DMLC is a good all around solution that I highly recommend for
consuming messages. The CachingConnectionFactory is also good for
sending messages because it can cache producers and sessions.

The last bit needed then is a JMS message producer. For this I
recommend the Spring JmsTemplate:

Just make sure to use the CachingConnectionFactory with the
JmsTemplate so that JMS connections are not repeatedly created and
destroyed for every send.

Together, these tools will speed your JMS development markedly.

perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"

ActiveMQ in Action:

View raw message