/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination) throws JMSException { return createConsumer(destination, (String) null); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException { return createConsumer(destination, null, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination, * using a message selector. Since <CODE> Queue</CODE> and * <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they * can be used in the destination parameter to create a * <CODE>MessageConsumer</CODE>. * <P> * A client uses a <CODE>MessageConsumer</CODE> object to receive messages * that have been sent to a destination. * * @param destination the <CODE>Destination</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @return the MessageConsumer * @throws JMSException if the session fails to create a MessageConsumer due * to some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { return createConsumer(destination, messageSelector, false); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination, * using a message selector. Since <CODE> Queue</CODE> and * <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they * can be used in the destination parameter to create a * <CODE>MessageConsumer</CODE>. * <P> * A client uses a <CODE>MessageConsumer</CODE> object to receive messages * that have been sent to a destination. * * @param destination the <CODE>Destination</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a MessageConsumer due * to some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, String messageSelector, MessageListener messageListener) throws JMSException { return createConsumer(destination, messageSelector, false, messageListener); }
return createConsumer(destination, messageSelector, noLocal, null);
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException { return createConsumer(destination, null, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination) throws JMSException { return createConsumer(destination, (String) null); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException { return createConsumer(destination, null, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException { return createConsumer(destination, null, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination) throws JMSException { return createConsumer(destination, (String) null); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination) throws JMSException { return createConsumer(destination, (String) null); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException { return createConsumer(destination, null, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination. * Since <CODE>Queue</CODE> and <CODE> Topic</CODE> both inherit from * <CODE>Destination</CODE>, they can be used in the destination * parameter to create a <CODE>MessageConsumer</CODE>. * * @param destination the <CODE>Destination</CODE> to access. * @return the MessageConsumer * @throws JMSException if the session fails to create a consumer due to * some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination) throws JMSException { return createConsumer(destination, (String) null); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination, * using a message selector. Since <CODE> Queue</CODE> and * <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they * can be used in the destination parameter to create a * <CODE>MessageConsumer</CODE>. * <P> * A client uses a <CODE>MessageConsumer</CODE> object to receive messages * that have been sent to a destination. * * @param destination the <CODE>Destination</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a MessageConsumer due * to some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, String messageSelector, MessageListener messageListener) throws JMSException { return createConsumer(destination, messageSelector, false, messageListener); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination, * using a message selector. Since <CODE> Queue</CODE> and * <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they * can be used in the destination parameter to create a * <CODE>MessageConsumer</CODE>. * <P> * A client uses a <CODE>MessageConsumer</CODE> object to receive messages * that have been sent to a destination. * * @param destination the <CODE>Destination</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @return the MessageConsumer * @throws JMSException if the session fails to create a MessageConsumer due * to some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ @Override public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { return createConsumer(destination, messageSelector, false); }
/** * Creates a <CODE>MessageConsumer</CODE> for the specified destination, * using a message selector. Since <CODE> Queue</CODE> and * <CODE>Topic</CODE> both inherit from <CODE>Destination</CODE>, they * can be used in the destination parameter to create a * <CODE>MessageConsumer</CODE>. * <P> * A client uses a <CODE>MessageConsumer</CODE> object to receive messages * that have been sent to a destination. * * @param destination the <CODE>Destination</CODE> to access * @param messageSelector only messages with properties matching the message * selector expression are delivered. A value of null or an * empty string indicates that there is no message selector * for the message consumer. * @param messageListener the listener to use for async consumption of messages * @return the MessageConsumer * @throws JMSException if the session fails to create a MessageConsumer due * to some internal error. * @throws InvalidDestinationException if an invalid destination is * specified. * @throws InvalidSelectorException if the message selector is invalid. * @since 1.1 */ public MessageConsumer createConsumer(Destination destination, String messageSelector, MessageListener messageListener) throws JMSException { return createConsumer(destination, messageSelector, false, messageListener); }
public MessageConsumer createConsumer(Destination destination) throws JMSException { return addConsumer(getSession().createConsumer(destination)); }
public MessageConsumer createConsumer(Destination destination, String selector, boolean noLocal) throws JMSException { return addConsumer(getSession().createConsumer(destination, selector, noLocal)); }
public MessageConsumer createConsumer(Destination destination, String selector) throws JMSException { return addConsumer(getSession().createConsumer(destination, selector)); }
@Test public void testPassMessageListenerIntoCreateConsumer() throws Exception { final AtomicInteger counter = new AtomicInteger(0); final CountDownLatch done = new CountDownLatch(1); // Receive a message with the JMS API connection.start(); ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQDestination destination = createDestination(session, destinationType); MessageConsumer consumer = session.createConsumer(destination, new MessageListener() { @Override public void onMessage(Message m) { counter.incrementAndGet(); if (counter.get() == 4) { done.countDown(); } } }); assertNotNull(consumer); // Send the messages sendMessages(session, destination, 4); assertTrue(done.await(1000, TimeUnit.MILLISECONDS)); Thread.sleep(200); // Make sure only 4 messages were delivered. assertEquals(4, counter.get()); }