Example usage for javax.jms XASession getSession

List of usage examples for javax.jms XASession getSession

Introduction

In this page you can find the example usage for javax.jms XASession getSession.

Prototype

Session getSession() throws JMSException;

Source Link

Document

Gets the session associated with this XASession .

Usage

From source file:org.mule.transport.jms.xa.SessionInvocationHandler.java

public SessionInvocationHandler(XASession xaSession, Boolean sameRMOverrideValue) throws JMSException {
    this(xaSession, xaSession.getSession(), sameRMOverrideValue);
}

From source file:org.wso2.carbon.transport.jms.sender.sessionpool.SessionPoolFactory.java

@Override
public synchronized SessionWrapper create() throws Exception {
    List<ConnectionWrapper> connectionWrappers;
    ConnectionWrapper connectionWrapper = null;
    SessionWrapper sessionWrapper = null;

    if (jmsConnectionFactory instanceof JMSClientConnectionFactory) {
        connectionWrappers = ((JMSClientConnectionFactory) jmsConnectionFactory).getConnections();

        // see if we can create more sessions on the final Connection created
        if (!connectionWrappers.isEmpty() && connectionWrappers.get(connectionWrappers.size() - 1)
                .getSessionCount()//from   w w w  .  j a va2s  . co m
                .get() < ((JMSClientConnectionFactory) jmsConnectionFactory).getMaxSessionsPerConnection()) {
            connectionWrapper = connectionWrappers.get(connectionWrappers.size() - 1);
        }

        // if it needs to create a new connectionWrapper
        if (connectionWrapper == null) {
            if (jmsConnectionFactory.isxATransacted()) {
                connectionWrapper = new ConnectionWrapper((jmsConnectionFactory.createXAConnection()));
            } else {
                connectionWrapper = new ConnectionWrapper(jmsConnectionFactory.createConnection());
            }
            connectionWrappers.add(connectionWrapper);
        }

        // Create new SessionWrapper (or XASessionWrapper) accordingly
        if (jmsConnectionFactory.isxATransacted()) {
            XASession xASession = jmsConnectionFactory
                    .createXASession((XAConnection) connectionWrapper.getConnection());
            sessionWrapper = new XASessionWrapper(xASession, xASession.getSession(),
                    jmsConnectionFactory.createMessageProducer(xASession.getSession()));
        } else {
            Session session = jmsConnectionFactory.createSession(connectionWrapper.getConnection());
            sessionWrapper = new SessionWrapper(session, jmsConnectionFactory.createMessageProducer(session));
        }
        connectionWrapper.incrementSessionCount();
    }
    return sessionWrapper;
}