Example usage for javax.jms Session createSharedDurableConsumer

List of usage examples for javax.jms Session createSharedDurableConsumer

Introduction

In this page you can find the example usage for javax.jms Session createSharedDurableConsumer.

Prototype

MessageConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector)
        throws JMSException;

Source Link

Document

Creates a shared durable subscription on the specified topic (if one does not already exist), specifying a message selector, and creates a consumer on that durable subscription.

Usage

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public MessageConsumer createMessageConsumer(Session session, Destination destination) {
    try {//from   w ww.jav a 2 s  .co  m
        if (JMSConstants.JMS_SPEC_VERSION_2_0.equals(jmsSpec) && isSharedSubscription) {
            if (isDurable) {
                return session.createSharedDurableConsumer((Topic) destination, subscriptionName,
                        messageSelector);
            } else {
                return session.createSharedConsumer((Topic) destination, subscriptionName, messageSelector);
            }
        } else if ((JMSConstants.JMS_SPEC_VERSION_1_1.equals(jmsSpec))
                || (JMSConstants.JMS_SPEC_VERSION_2_0.equals(jmsSpec) && !isSharedSubscription)) {
            if (isDurable) {
                return session.createDurableSubscriber((Topic) destination, subscriptionName, messageSelector,
                        noPubSubLocal);
            } else {
                return session.createConsumer(destination, messageSelector);
            }
        } else {
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                return ((QueueSession) session).createReceiver((Queue) destination, messageSelector);
            } else {
                if (isDurable) {
                    return ((TopicSession) session).createDurableSubscriber((Topic) destination,
                            subscriptionName, messageSelector, noPubSubLocal);
                } else {
                    return ((TopicSession) session).createSubscriber((Topic) destination, messageSelector,
                            false);
                }
            }
        }
    } catch (JMSException e) {
        logger.error("JMS Exception while creating consumer. " + e.getMessage(), e);
    }
    return null;
}