@JMS2_0 public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) throws JMSException { MessageConsumer mc = delegate.createSharedConsumer(topic, sharedSubscriptionName, messageSelector); return TracingMessageConsumer.create(mc, jmsTracing); }
consumer = (durable ? this.target.createSharedDurableConsumer((Topic) dest, subscription, selector) : this.target.createSharedConsumer((Topic) dest, subscription, selector));
@JMS2_0 public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException { MessageConsumer mc = delegate.createSharedConsumer(topic, sharedSubscriptionName); return TracingMessageConsumer.create(mc, jmsTracing); }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
/** * Create a JMS MessageConsumer for the given Session and Destination. * <p>This implementation uses JMS 1.1 API. * @param session the JMS Session to create a MessageConsumer for * @param destination the JMS Destination to create a MessageConsumer for * @return the new JMS MessageConsumer * @throws javax.jms.JMSException if thrown by JMS API methods */ protected MessageConsumer createConsumer(Session session, Destination destination) throws JMSException { if (isPubSubDomain() && destination instanceof Topic) { if (isSubscriptionShared()) { return (isSubscriptionDurable() ? session.createSharedDurableConsumer((Topic) destination, getSubscriptionName(), getMessageSelector()) : session.createSharedConsumer((Topic) destination, getSubscriptionName(), getMessageSelector())); } else if (isSubscriptionDurable()) { return session.createDurableSubscriber( (Topic) destination, getSubscriptionName(), getMessageSelector(), isPubSubNoLocal()); } else { // Only pass in the NoLocal flag in case of a Topic (pub-sub mode): // Some JMS providers, such as WebSphere MQ 6.0, throw IllegalStateException // in case of the NoLocal flag being specified for a Queue. return session.createConsumer(destination, getMessageSelector(), isPubSubNoLocal()); } } else { return session.createConsumer(destination, getMessageSelector()); } }
private MessageConsumer createMessageConsumer(final Session session, final String destinationName, final boolean durable, final boolean shared, final String subscriberName) throws JMSException { final boolean isPubSub = JMSConsumer.this.jmsTemplate.isPubSubDomain(); final Destination destination = JMSConsumer.this.jmsTemplate.getDestinationResolver().resolveDestinationName(session, destinationName, isPubSub); if (isPubSub) { if (shared) { try { if (durable) { return session.createSharedDurableConsumer((Topic) destination, subscriberName); } else { return session.createSharedConsumer((Topic) destination, subscriberName); } } catch (AbstractMethodError e) { throw new ProcessException("Failed to create a shared consumer. Make sure the target broker is JMS 2.0 compliant.", e); } } else { if (durable) { return session.createDurableConsumer((Topic) destination, subscriberName, null, JMSConsumer.this.jmsTemplate.isPubSubDomain()); } else { return session.createConsumer(destination, null, JMSConsumer.this.jmsTemplate.isPubSubDomain()); } } } else { return session.createConsumer(destination, null, JMSConsumer.this.jmsTemplate.isPubSubDomain()); } }
@Override public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) throws JMSException { return session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector); }
@Override public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException { return session.createSharedConsumer(topic, sharedSubscriptionName); }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Test public void testSharedConsumer() throws Exception { conn = cf.createConnection(); conn.start(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); topic = ActiveMQJMSClient.createTopic(T_NAME); MessageConsumer cons = session.createSharedConsumer(topic, "test1"); MessageProducer producer = session.createProducer(topic); producer.send(session.createTextMessage("test")); TextMessage txt = (TextMessage) cons.receive(5000); Assert.assertNotNull(txt); }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(final Topic topic, final String sharedSubscriptionName, final String messageSelector) { try { final JMSConsumerImpl consumer = new JMSConsumerImpl(this, session().createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (final JMSException e) { throw toRuntimeException(e); } }
/** * Delegates the call to the wrapped JMS session. */ public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, this + " createSharedConsumer(" + topic + ", " + sharedSubscriptionName + ")"); checkValidity(); return new OutboundConsumer(sess.createSharedConsumer(topic, sharedSubscriptionName), this); }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { checkSession(); try { ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); checkAutoStart(); return consumer; } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } }
@Override public JMSConsumer createSharedConsumer(final Topic topic, final String sharedSubscriptionName) { try { final JMSConsumerImpl consumer = new JMSConsumerImpl(this, session().createSharedConsumer(topic, sharedSubscriptionName)); checkAutoStart(); return consumer; } catch (final JMSException e) { throw toRuntimeException(e); } }