List of usage examples for javax.jms TopicSession createDurableSubscriber
TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException;
From source file:org.aludratest.service.jms.impl.JmsActionImpl.java
@Override public void subscribeTopic(MessageListener listener, @TechnicalLocator String destinationName, @TechnicalArgument String messageSelector, @TechnicalArgument String subscriptionName, @TechnicalArgument boolean durable) throws JMSException { if (StringUtils.isEmpty(subscriptionName)) { throw new IllegalArgumentException("subscriptionName must be provided to subscribe!"); }//from w ww .j a v a 2 s . com Topic topic; try { topic = (Topic) context.lookup(destinationName); } catch (NamingException e) { throw new AutomationException("Could not lookup destination " + destinationName, e); } LOGGER.debug("Creating topic-subscriber for topic " + destinationName + " and subscriptionname " + subscriptionName); Connection c = getDynamicConnection(subscriptionName); TopicSession ts = (TopicSession) c.createSession(false, Session.AUTO_ACKNOWLEDGE); if (durable) { TopicSubscriber subscriber = ts.createDurableSubscriber(topic, subscriptionName, messageSelector, false); subscriber.setMessageListener(listener); this.durableConsumers.put(subscriptionName, subscriber); } else { ts.createSubscriber(topic, messageSelector, true).setMessageListener(listener); } }
From source file:nl.nn.adapterframework.jms.JMSFacade.java
private TopicSubscriber getTopicSubscriber(TopicSession session, Topic topic, String selector) throws NamingException, JMSException { TopicSubscriber topicSubscriber;/* w w w .j ava 2s . com*/ if (subscriberType.equalsIgnoreCase("DURABLE")) { topicSubscriber = session.createDurableSubscriber(topic, destinationName, selector, false); if (log.isDebugEnabled()) log.debug("[" + name + "] got durable subscriber for topic [" + destinationName + "] with selector [" + selector + "]"); } else { topicSubscriber = session.createSubscriber(topic, selector, false); if (log.isDebugEnabled()) log.debug("[" + name + "] got transient subscriber for topic [" + destinationName + "] with selector [" + selector + "]"); } return topicSubscriber; }