List of usage examples for javax.jms TopicSubscriber close
void close() throws JMSException;
From source file:org.apache.stratos.lb.endpoint.subscriber.TopologySubscriber.java
public static void subscribe(String topicName) { Properties initialContextProperties = new Properties(); TopicSubscriber topicSubscriber = null; TopicSession topicSession = null;/*from w w w . j a va2 s .c om*/ TopicConnection topicConnection = null; InitialContext initialContext = null; initialContextProperties.put("java.naming.factory.initial", "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"); String mbServerUrl = null; if (ConfigHolder.getInstance().getLbConfig() != null) { mbServerUrl = ConfigHolder.getInstance().getLbConfig().getLoadBalancerConfig().getMbServerUrl(); } String connectionString = "amqp://admin:admin@clientID/carbon?brokerlist='tcp://" + (mbServerUrl == null ? TopologyConstants.DEFAULT_MB_SERVER_URL : mbServerUrl) + "'&reconnect='true'"; initialContextProperties.put("connectionfactory.qpidConnectionfactory", connectionString); try { initialContext = new InitialContext(initialContextProperties); TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) initialContext .lookup("qpidConnectionfactory"); topicConnection = topicConnectionFactory.createTopicConnection(); topicConnection.start(); topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = topicSession.createTopic(topicName); topicSubscriber = topicSession.createSubscriber(topic); topicSubscriber.setMessageListener(new TopologyListener()); } catch (Exception e) { log.error(e.getMessage(), e); try { if (topicSubscriber != null) { topicSubscriber.close(); } if (topicSession != null) { topicSession.close(); } if (topicConnection != null) { topicConnection.close(); } } catch (JMSException e1) { // ignore } } finally { // start the health checker Thread healthChecker = new Thread(new TopicHealthChecker(topicName, topicSubscriber)); healthChecker.start(); } }
From source file:org.grouter.common.jms.TopicSenderDestination.java
@Override public Message waitAndGetReplyFromTemporaryDestination(long waitForMs) { TopicSubscriber receiver = null; try {//from w w w. j ava2s .c o m if (!useTemporaryReplyDestination) { throw new IllegalStateException("You have used this destination in a wrong way. Have you " + "used correct constructor for temporary destinations?"); } receiver = topicSession.createSubscriber(getTemporaryDestination()); return receiver.receive(waitForMs); } catch (JMSException ex) { logger.warn("Waiting for reply on temp topic failed", ex); return null; } finally { try { if (receiver != null) { receiver.close(); } } catch (JMSException ex1) { //ignore } } }
From source file:org.wso2.carbon.bpmn.extensions.jms.JMSMessageSender.java
public void createTempTopicSubscriber() throws JMSException { TopicSubscriber subscriber = ((TopicSession) session).createSubscriber((Topic) destination); subscriber.close(); }