4 Replies Latest reply on Jul 17, 2008 2:45 PM by janylj

    How to set up a durable subscriber?

    janylj

      Hello,

      I am trying to establish publish-durable subscriber using JBoss Messaging 1.4.1.Beta1 and AS 4.2.2.GA.
      Though I was able to publish messages to topic , my subscriber couldn't read the messages from topic. Are there any configurations to follow to setup durable subscriber?

      destinations-service.xml:

      <mbean code="org.jboss.jms.server.destination.TopicService"
       name="jboss.messaging.destination:service=Topic,name=RemotehostDurableTopic"
       xmbean-dd="xmdesc/Topic-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       <attribute name="SecurityConfig">
       <security>
       <role name="guest" read="true" write="true"/>
       <role name="publisher" read="true" write="true" create="false"/>
       <role name="durpublisher" read="true" write="true" create="true"/>
       </security>
       </attribute>
       </mbean>


      I am using external Java clients (producers and consumers).
      Topic topic = (Topic) iniCtx.lookup("topic/RemotehostDurableTopic");
       TopicSession session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
       TopicSubscriber recv = session.createDurableSubscriber(topic, "sub1");


      Thank you very much.

      Best,
      Lijun


        • 1. Re: How to set up a durable subscriber?
          ataylor

          Are you sure you are starting the connection? i.e. connection.start()

          • 2. Re: How to set up a durable subscriber?
            janylj

            Yes. I started the connection.

            Actually I am using the same code to connect to a topic. Everything runs OK. For the durable subscriber, I just look up another destination.

            if (client.isDurable()) {
             String clientName = getClientName();
             LOG.info("Creating durable subscriber (" + clientName + ") to: " + dest.toString());
             jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName);
             } else {
             LOG.info("Creating non-durable consumer to: " + dest.toString());
             jmsConsumer = getSession().createConsumer(dest);
             }


            • 3. Re: How to set up a durable subscriber?
              jmesnil

               

              "janylj" wrote:

              if (client.isDurable()) {
               String clientName = getClientName();
               LOG.info("Creating durable subscriber (" + clientName + ") to: " + dest.toString());
               jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName);
               } else {
               LOG.info("Creating non-durable consumer to: " + dest.toString());
               jmsConsumer = getSession().createConsumer(dest);
               }


              In both case, you use the same destination "dest".
              Do you mean that if you client is durable, the jmsConsumer does not receive any message from the topic? while it is not durable, it receives message?

              • 4. Re: How to set up a durable subscriber?
                janylj

                Exactly.

                The destination is what I posted above. When it's not a durable subscriber, receiving is OK. But when it's a durable subscriber, it doesn't get any message.