0 Replies Latest reply on Jun 6, 2005 8:19 AM by sriramp_here

    Durable Subscription

      Hi
      I have a question regarding making a subscription durable. I went a lot through the documentation but still i am not able to get it right.
      This is my publisher code only part of it.

      Context ctxInitCtxt = new InitialContext();
      TopicConnectionFactory factory = (TopicConnectionFactory)ctxInitCtxt.lookup("ConnectionFactory");
      topicConn= factory.createTopicConnection();
      topicSession= topicConn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      Topic topic = (Topic) ctxInitCtxt.lookup("topic/DEFTopic");
      TopicPublisher publisher = topicSession.createPublisher(topic);
      ObjectMessage objMsg =topicSession.createObjectMessage();
      objMsg.setObject(dfrep);
      publisher.publish(objMsg);

      I guess the durable subscription should happen from the client. Now i have an MDB which listens to this topic.

      My MDB

      public void onMessage(Message msg)
      {
      ObjectMessage objMsg = (ObjectMessage) msg;
      String strClassName=this.getClass().getName();
      try
      {
      Report dfrpt = (Report)objMsg.getObject();
      // The bean has received the following message from the JMS Queue.
      DEFLogger.logInfo("["+className+"]"+"Mesasge driven Bean(MDB) has received the message with reportClassName-->"+dfrpt.getReportClassName() );
      ReportController.extractKXMLDoc(dfrpt);

      }
      catch(Exception ex)
      {
      DEFLogger.logFatal(ex);
      }
      }


      My jboss.xml is

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">


      <enterprise-beans>

      <ejb-name>DEFReportEJB</ejb-name>
      <jndi-name>DEFReportEJB</jndi-name>

      <message-driven>
      <ejb-name>DEFReportMDB</ejb-name>
      <destination-jndi-name>topic/DEFTopic</destination-jndi-name>
      </message-driven>
      </enterprise-beans>
      <resource-managers>
      </resource-managers>


      My ejb-jar.xml is


      <?xml version = '1.0' encoding = 'windows-1252'?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>
      <message-driven>
      Message Driven Bean
      <display-name>DEFReportMDB</display-name>
      <ejb-name>DEFReportMDB</ejb-name>
      <ejb-class>com.ketera.dataextraction.common.DEFReportMDBBean</ejb-class>
      <message-driven-destination>
      <destination-type>javax.jms.Topic</destination-type>
      <subscription-durability>durable</subscription-durability>
      </message-driven-destination>
      <transaction-type>Container</transaction-type>
      <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
      </message-driven>
      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>DEFReportEJB</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

      Can anyone help me out in this regard.