0 Replies Latest reply on Sep 22, 2010 4:31 AM by xufang

    How to enable auto-generated ClientID when creating durable subscription for a JMS Topic?

    xufang

      Hi All,

       

      I met a JMS problem when recently upgraded to JBoss 5.1.0GA from JBoss 4.0.3SP1.

       

      When using JBoss 4.0.3SP1, JBossMQ can create a unique ClientID automatically when creating a durable subscription for a JMS topic if no clientID specified. The code is as below:

       

         Context jndiContext=this.createInitContext(this.initFile);
         TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory)jndiContext.lookup("ConnectionFactory");
         Topic topic = (Topic) jndiContext.lookup("topic/"+this.initFile.getTopicName());
         topicConnection=topicConnectionFactory.createTopicConnection();

         topicSession = null;
         if (this.initFile.getClientID()==null || "".equals(this.initFile.getClientID()))
         {
          topicSession=topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
          this.initFile.setClientID(topicConnection.getClientID());

         }

       

      After topicConnection.createTopicSession, a ClientID will be created by JBossMQ and by calling topicConnection.getClientID(), the clientID can be got and stored locally.

       

      But after upgraded to JBoss 5.1.0GA which is using JBossMessaging, the above code is not working any more. TopicConnection.getClientID() always return null. I must specify the ClientID explicitly otherwise the subscription cannot be successful.

       

      I am wondering how can I enable the ClientID auto-generated function in JBoss 5.1.0GA. Please enlighten me.

       

      Thanks & Best Regards,

      Xu Fang