Announcement Announcement Module
No announcement yet.
How to unsubscribe() a durable subscriber from DefaultMessageListenerContainer? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to unsubscribe() a durable subscriber from DefaultMessageListenerContainer?

    I set up a DefaultMessageListenerContainer for a durable subscriber. After running my test program, the container bean should be destroyed and all the resources should be released. However, from ActiveMQ admin console, the number of consumer is still '1'. It seems that the durable subscriber is closed but not unsubscribed. Is there any way from DefaultMessageListenerContainer to permanently unsubscribe it?

    <bean id="jmsDurableTopicContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="connectionFactory" ref="jmsFactory"/>
    <property name="destination" ref="durableTopic"/>
    <property name="subscriptionDurable" value="true"/>
    <property name="durableSubscriptionName" value="TestDurableSub"/>
    <property name="clientId" value="TestConnection"/>

    Thank you.

  • #2
    If you want your subscription to go away when your JVM closes - maybe you don't want a durable subscription?

    Note that a durable JMS subscription is only used when you explicitly dont want your subscription to go away when the JVM goes away.

    If you only want to receive messages when your JVM is active, use a normal topic subscription.

    Note that durability of subscription != durability of messages.

    e.g. a non durable topic subscription can subscribe to both durable and non-durable messages


    • #3
      OK. I understand that durable subscriber will not go away when JVM closes. It's exactly what my use case for durable subscriber to receive messages during its downtime. However, how to permanently unsubscribe the durable subscriber? I don't want the durable subscriber automatically be unsubscribed when the JVM closes. But I could not find an explicit unsubscribe() from DefaultMessageListenerContainer.

      Thanks a lot for the input.


      • #4
        Hi janylj,

        Have you found solution for this? How to unsubscribe from a durable subscription when it is created using DefaultMessageListenerContainer bean?