Example usage for javax.jms QueueSession createReceiver

List of usage examples for javax.jms QueueSession createReceiver

Introduction

In this page you can find the example usage for javax.jms QueueSession createReceiver.

Prototype


QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException;

Source Link

Document

Creates a QueueReceiver object to receive messages from the specified queue using a message selector.

Usage

From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSource.java

@Override
public void run(final SourceContext<T> context) throws Exception {
    QueueSession session = null;
    QueueReceiver consumer = null;//from  www.j  av a 2 s . c o  m

    try {
        session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        consumer = session.createReceiver(destination, messageSelector);

        connection.start();

        while (isRunning) {
            context.collect(convert(consumer.receive()));
        }
    } catch (JMSException e) {
        logger.error("Error receiving message from [{}]: {}", destination.getQueueName(),
                e.getLocalizedMessage());
        throw new UncategorizedJmsException(e);
    } finally {
        JmsUtils.closeMessageConsumer(consumer);
        JmsUtils.closeSession(session);
    }
}

From source file:nl.nn.adapterframework.jms.JMSFacade.java

/**
 *  Gets a queueReceiver/*www  . ja v a2s .  c  om*/
 * @see javax.jms.QueueReceiver
 * @return                                   The queueReceiver value
 * @exception  javax.naming.NamingException  Description of the Exception
 * @exception  javax.jms.JMSException                  Description of the Exception
 */
private QueueReceiver getQueueReceiver(QueueSession session, Queue destination, String selector)
        throws NamingException, JMSException {
    QueueReceiver queueReceiver = session.createReceiver(destination, selector);
    return queueReceiver;
}