[jboss-user] [Messaging, JMS & JBossMQ] - DurableSubscriber

jp_ammu do-not-reply at jboss.com
Thu Jun 14 19:57:15 EDT 2007


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? 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054583#4054583

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054583



More information about the jboss-user mailing list