Results 1 to 3 of 3

Thread: Spring JMS + Active MQ

  1. #1
    Join Date
    Sep 2008
    Posts
    2

    Default 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]

  2. #2
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    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.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

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
  •