Meaningless Drivel is fun!*
The moose likes Spring and the fly likes DefaultMessageListenerContainer not getting started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "DefaultMessageListenerContainer not getting started" Watch "DefaultMessageListenerContainer not getting started" New topic
Author

DefaultMessageListenerContainer not getting started

Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
Hi,

Here is the problem I am facing.

I have topic connection factory.



This is working fine, When server is available I am able to publish message and in case if its not available it throws error.

I have two other subscribers which are listening to topic. As I have made lookupOnStartup property false for my topic and connection factory, listeners are not starting at all.

Here is topic and listener configuration.



Any idea, how listeners can be started ? I tried to lookup listener bean and calling start method, but no success.

Regards,
Anand


~ Anand,
SCJP 1.5, SCWCD 1.5
Bruce Snyder
author
Greenhorn

Joined: Nov 03, 2010
Posts: 10
By default, the DMLC will start up automatically when the Spring application context is started. This is controlled by the autoStartup property in the AbstractJmsListeningContainer set to true. There's no need to start up the listeners as you mentioned because they get invoked each time a message arrives in the DMLC.

Which message listener interface does your TCDataSubscriber bean implement? For more info, see the Spring Reference Doc's section named Receiving a message.

Bruce
Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
Hi Bruce,

Thanks for the quick reply.

My TCDataSubsciber implements javax.jms.MessageListener.

When I stop JMS server application throws exception saying Destination Unreachable. When I start JMS server again I can not see the DMLC created threads running.
How to test if DMLC tries to reconnect ?

Regards,
Anand
Bruce Snyder
author
Greenhorn

Joined: Nov 03, 2010
Posts: 10
As the error indicates, the destination cannot be reached. Can you send messages to the topic using that connection?

I find it easiest to troubleshoot situations by breaking things down to the simplest possible case. Using the Spring SingleConnectionFactory and JmsTemplate, I would do this:

  • Look up the connection
  • Send a message
  • Receive a message

  • If that works, then receive the message using the Spring DMLC and a listener instead of the JmsTemplate.

    Hope that helps.

    Bruce
    Anand Loni
    Ranch Hand

    Joined: Jan 20, 2006
    Posts: 150
    Hi Bruce,

    I have made property autoStartUp as false for my listeners, and I am starting DMLC in my context loader. I am using weblogic as application server. Now I am getting below error:




    I made sure that client Id and subscription name are unique for each listener. Any idea what went wrong ?
    Bruce Snyder
    author
    Greenhorn

    Joined: Nov 03, 2010
    Posts: 10
    Well the error states that 'Client id, TCAnsPaperSubscriber471, is in use.' So it seems like a client id is being used twice. The error detail is also telling you where that client id is being used:

    "The JNDI name weblogic.jms.connection.clientid.TCAnsPaperSubscriber471 was found, and was bound to an object of type weblogic.jms.frontend.FEClientIDSingularAggregatable : FEClientIDSingularAggregatable(SingularAggregatable(<6176547454817656908.1>:302):TCAnsPaperSubscriber471)"


    Bruce
    Anand Loni
    Ranch Hand

    Joined: Jan 20, 2006
    Posts: 150
    Hi Bruce,

    Sorry, but I am not getting where client id is being used twice from the error message.

    Regard,
    Anand Loni
    Ranch Hand

    Joined: Jan 20, 2006
    Posts: 150
    Hi Bruce,

    When I looked up into my JMS server, I found that there is active connection for TCAnsPaperSubscriber471. When I destroy connection and then start my weblogic server where I deployed my application, I do not get "Client id in use" error. When Application gets up I can see active connection for TCAnsPaperSubscriber471. If I restart weblogic server again without destroying connection then I get the same error "Client Id in use".

    Is this related to autoStartup property being false for DMLC ? If yes how can I destroy connection when my application/server goes down?

    Regards,
    Bruce Snyder
    author
    Greenhorn

    Joined: Nov 03, 2010
    Posts: 10
    If the JndiObjectFactoryBean and the DMLC are both not marked to not start up by default, then I'm not sure where the connection is coming from. If I had this problem, I would grab a thread dump from the app while it's running so that I could locate the stack trace containing the JMS Connection object. This might help you understand where the connection is originating.

    Bruce
    Anand Loni
    Ranch Hand

    Joined: Jan 20, 2006
    Posts: 150
    Hi Bruce,

    Is there any way, by which I can check if there is any subscriber with the same client Id. If its there then destroy that subscriber and start subscriber again.

    I tried to implement my class implementing disposable bean and in the destroy method I called stop method on the DMLC. But when I stop server, destroy method is not called at all.

    Any idea, how I can resolve this issue ?

    Regards,
    Anand Loni
    Ranch Hand

    Joined: Jan 20, 2006
    Posts: 150
    Finally I resolved this issue.

    I added shutdown hook and stopped DMLC. This hook will be called when jvm exits.

    Here is code :



    Thanks.
     
    GeeCON Prague 2014
     
    subject: DefaultMessageListenerContainer not getting started