3 Replies Latest reply on Jun 18, 2007 10:07 AM by Adrian Brock

    DurableSubscriber

    jaya ammu Newbie

      Hi All,
      I am creating DurableSubscribers on a remote JMS topic. Here code snippet. Iam using a seesion Bean with Message Listener. Iam using Jboss and Oracle JMS

      public void connect(){
      tcf = new STCTopicConnectionFactory(RibHost, rib_port);
      topicConnection = tcf.createTopicConnection();
      logger.debug(" topicConnection Created "+topicConnection);
      //Stop the connection if

      topicSession = topicConnection.createTopicSession(false,
      Session.AUTO_ACKNOWLEDGE);
      logger.debug(" TopicSession Created "+topicSession);
      // temporarly stop the connection for incomiing messages
      if(topicConnection!=null)topicConnection.stop();

      topic = topicSession.createTopic(TMP_PRC_TOPIC);
      logger.debug("Topic Created >>>>> "+topic);
      try{
      topicSubscriber = topicSession.createDurableSubscriber(topic, "SH_CLR_PRC_CHG");

      }catch(Exception e){
      System.out.println(" Exception Creating DurableSubscriber SH_CLR_PRC_CHG "+e.getMessage());
      }
      logger.debug("Subscriber Created >>>>> "+topicSubscriber);
      topicSubscriber.setMessageListener(this);
      topicConnection.setExceptionListener(this);
      topicConnection.start();

      }

      Topic being created on subscription name SH_CLR_PRC_CHG and messages are comming. But When i restart my application,
      1) If no messages are there on the subscription in remote jms server, the connection is created fine
      2) If there are some messages are already in the subscription, the createDurableSubscriber() throws exception saying the subsctiption name already exists. and conenction fails.

      How do solve this problem. Before creating topicSession.createDurableSubscriber(), is there any way i can check if the subsription name exists or any flag of createDurableSubscriber() that enforces reassigning the same subscription name

      Any advises please?

        • 1. Re: DurableSubscriber
          Adrian Brock Master

          This just looks like you are doing it wrong - an anti-pattern.

          Session beans can "vanish at anytime" and are certainly not the place
          to establish long lived jms connections for receiving. That is what MDBs are for.

          • 2. Re: DurableSubscriber
            jaya ammu Newbie

            Hi Adrian,
            Yes you are right. We were not able to configure RemoteTopic ( to Sun eGate eWays JMS server) from the MDB residing on JBOSS. I haven't seen much info in configuring the remote invokes from JBOSS.Hence we used Session bean to directly calling the remote topics.

            Even if able to configure the MDB succesfully, i still have DurableSubscriber() with same subscription name. My application( after restart) will get the duplicate subscription name exception and can't proceed further.

            • 3. Re: DurableSubscriber
              Adrian Brock Master

               

              "jp_ammu" wrote:

              Even if able to configure the MDB succesfully, i still have DurableSubscriber() with same subscription name. My application( after restart) will get the duplicate subscription name exception and can't proceed further.


              ???? Restarting an MDB will close the previous connection so the client id/subscritpion name
              will not be a duplicate. The MDB uses only one connection with many sessions.