activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Suchitha Koneru \(sukoneru\)" <sukon...@cisco.com>
Subject durable subscriptions not working
Date Fri, 09 Feb 2007 20:08:39 GMT
Hello active mq users , 
                I have Java 1.5.09 , Tomcat 5.5 .
 I am using the following active mq jars activemq-core-4.0.1.jar ,
backport-util-concurrent-2.1.jar , geronimo-j2ee-
management_1.0_spec-1.0.jar, geronimo-jms_1.1_spec-1.0.jar ,
incubator-activemq-4.0.2.jar
 
I have two classes Herbie Publisher , Herbie Subscriber . The
ConnectionFactory and the Topic are mentioned as JNDI resources in
Tomcat/Conf/Context.xml 

        <Resource name="jms/ConnectionFactory" 
       auth="Container" 
       type="org.apache.activemq.ActiveMQConnectionFactory" 
       description="JMS Connection Factory"
             factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
             brokerURL="tcp://localhost:61616" 
             brokerName="LocalActiveMQBroker" 
             />
      
        <Resource name="jms/PNMTopic" 
             auth="Container" 
             type="org.apache.activemq.command.ActiveMQTopic" 
             description="the topic against which the client back end
will publish and server back end would subscribe"
 
factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
             physicalName="FOO3.BAR"/>
 
The code for Herbie Publisher is as follows 
//code for intialization 
Ictx = new InitialContext();

envContext =(Context ) Ictx.lookup("java:comp/env");

//code for getting connection  , creating session and publishing 
try{

javax.jms.TopicConnectionFactory factory =
(javax.jms.TopicConnectionFactory)envContext.lookup("jms/ConnectionFacto
ry");

// create a new TopicConnection for pub/sub messaging

HerbieTopicConnection  = factory.createTopicConnection();

topic = (Topic)envContext.lookup("jms/PNMTopic") ;

if(HerbieTopicConnection != null){

HerbieSession =
(ActiveMQSession)HerbieTopicConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

HerbieTopicConnection.start();

TopicPublisher pub = Sess.createPublisher(topic);

pub.setTimeToLive(10000);

pub.setDeliveryMode(DeliveryMode.PERSISTENT);

String msg = "This is a test message";

pub.send( Sess.createTextMessage(msg));

pub.close();

Sess.close();

HerbieTopicConnection.close();

}

catch(Exception e){

e.printStackTrace();

}

The Herbie Subscriber code is as follows 
// Intialiization same as Herbie Publisher , same as above
//establish connection, create durable subscriber and receive messages 
  
javax.jms.TopicConnectionFactory factory =
(javax.jms.TopicConnectionFactory)envContext.lookup("jms/ConnectionFacto
ry");

HerbieTopicConnection = factory.createTopicConnection();

topic = (Topic)envContext.lookup("jms/PNMTopic") ;

if(HerbieTopicConnection != null){

HerbieSession =
(ActiveMQSession)HerbieTopicConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

topic = (Topic)envContext.lookup("jms/PNMTopic") ;

//creating durable subscriber using topic and subscription name

TopicSubscriber Subs =
Sess.createDurableSubscriber(topic,"durablesubscription");

HerbieTopicConnection.setCleintID("CLIENTID");

HerbieTopicConnection.start();

public void onMessage(Message arg0) {

System.out.println("Received message: " + arg0.toString());

}

}
 
I do not see the messages getting exchanged. I am not sure , as to what
went wrong. Please let me know, If Iam missing anything in the
configuration. As of now,, I am using tuple(CLientID, Topic ,
subscription name) to uniquely identify the durable subscription.
 
thank you,
Suchitha.
 
 
 
 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message