• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMS Durable Subscriber message not picked from the Queue

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try {
ResourceProperties properties = ResourceProperties.getResourceInstance();
String initialContextUrl =  properties.getProperty("CONTEXT_URL");
String contextFactory =  "com.webmethods.jms.naming.WmJmsNamingCtxFactory";
String clientGroup="admin";

Properties env = new Properties();

env.setProperty(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
env.setProperty(Context.PROVIDER_URL, initialContextUrl);
env.setProperty("com.webmethods.jms.clientIDSharing", "true");
env.setProperty("com.webmethods.jms.naming.clientgroup", clientGroup);
env.put(Context.SECURITY_PRINCIPAL, "user");
env.put(Context.SECURITY_CREDENTIALS, "12345");
Context context = new InitialDirContext(env);
context.getEnvironment();
    connectionFactory = (WmConnectionFactory) context.lookup(properties.getProperty("ConnectionFactory"));          
    connectionFactory.setSSLTruststore(properties.getProperty("SSLPATH").trim());  
    subscriberTopicDest=(Topic)context.lookup("NotifyTest");
    System.setProperty("com.webmethods.jms.clientIDSharing", "true");
    connection = (Connection ) connectionFactory.createConnection("user","12345");
session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);


            // Create durable subscriber
             subscriber = session.createDurableSubscriber(subscriberTopicDest, "testDS");
   // subscriber = session.createConsumer(subscriberTopicDest);
subscriber.setMessageListener(this);

connection.start();
                       if(subscriber != null){
   subscriber.close();
   subscriber = null;
   System.out.println("JMS Subscriber Closed Successfully");
}

                        if(session != null){
session.close();
System.out.println("JMS session Closed Successfully");
session = null;
}
if(connection != null){
connection.close();
System.out.println("JMS connection Closed Successfully");
connection = null;
}  
LOGGER.info("JMS Update Deposit Limit Topic Created Successfully");
System.out.println("JMS Update Deposit Limit Topic Created Successfully");
} catch (Exception ex) {
LOGGER.info("JMS Update Deposit Limit Topic Creation Failed : "+ex.getMessage());
System.out.println("JMS Update Deposit Limit Topic Creation Failed : "+ex.getMessage());
ex.printStackTrace();
}

}

The above code is written for subscribing the message from a Topic and the messages are piled up in the queue. The messages are read only the services are started up. Is there any connection became idle when there is no messages are available in the queue.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic