-
Oct 16th, 2008, 07:27 PM
#1
Spring JMS + Active MQ
So I am doing this in my code <see code below> to start a consumer, I use JmsTemplate to create connectionFactory, then create a connection, do a start , obtain a session , then create a consumer and set the Message Listener.
So far so good, I am using Active MQ as the JMS provider, now if I use bring up my consumer for a destination(it's a queue) that is not created in ActiveMQ , everything works fine. My consumer picks up the messages to sent to the destination.
But the problem happens, when a queue is already created, when I start my consumer the consumer doesn't listen to the queue and doesn't pick up messages. Messages stay in the pending state. Is there a config I should change or am I doing something wrong while creating the consumer ?
----------------------------------------------------------------
template.setSessionAcknowledgeMode(Session.CLIENT_ ACKNOWLEDGE);
ConnectionFactory factory = template.getConnectionFactory();
connection = factory.createConnection();
connection.start();
session = connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
consumer = session.createConsumer(destination);
consumer.setMessageListener(this);[/HTML]
-
Oct 17th, 2008, 12:46 AM
#2
It seems that the problem is in your approach to get a target Destination handle. You can try to do the stuff (create MessageConsumer for the existing queue) manually (without Spring classes help) and check the result. I believe that you resolve the issue as soon as you have a working consumer created manually.
-
Oct 17th, 2008, 02:45 AM
#3
First off all your approach is a bit ackward. Why not use a MessageListenerContainer and register your MessageListener on there. That way you don't have to mess around yourself with connections, queues...
Also if you really want to use this approach (which I hardly recommend) I suggest using a SessionCallback instead of doing all the hard work yourself.
Still I would recommend a MessageListenerContainer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules