org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage

Here are the examples of the java api class org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage taken from open source projects.

1. ActiveMQClientProtocolManager#createSessionContext()

Project: activemq-artemis
File: ActiveMQClientProtocolManager.java
public SessionContext createSessionContext(Version clientVersion, String name, String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int minLargeMessageSize, int confirmationWindowSize) throws ActiveMQException {
    if (!isAlive())
        throw ActiveMQClientMessageBundle.BUNDLE.clientSessionClosed();
    Channel sessionChannel = null;
    CreateSessionResponseMessage response = null;
    boolean retry;
    do {
        retry = false;
        Lock lock = null;
        try {
            lock = lockSessionCreation();
            // We now set a flag saying createSession is executing
            synchronized (inCreateSessionGuard) {
                if (!isAlive())
                    throw ActiveMQClientMessageBundle.BUNDLE.clientSessionClosed();
                inCreateSession = true;
                inCreateSessionLatch = new CountDownLatch(1);
            }
            long sessionChannelID = connection.generateChannelID();
            Packet request = newCreateSessionPacket(clientVersion, name, username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge, minLargeMessageSize, confirmationWindowSize, sessionChannelID);
            try {
                // channel1 reference here has to go away
                response = (CreateSessionResponseMessage) getChannel1().sendBlocking(request, PacketImpl.CREATESESSION_RESP);
            } catch (ActiveMQException cause) {
                if (!isAlive())
                    throw cause;
                if (cause.getType() == ActiveMQExceptionType.UNBLOCKED) {
                    retry = true;
                    continue;
                } else {
                    throw cause;
                }
            }
            sessionChannel = connection.getChannel(sessionChannelID, confirmationWindowSize);
        } catch (Throwable t) {
            if (lock != null) {
                lock.unlock();
                lock = null;
            }
            if (t instanceof ActiveMQException) {
                throw (ActiveMQException) t;
            } else {
                throw ActiveMQClientMessageBundle.BUNDLE.failedToCreateSession(t);
            }
        } finally {
            if (lock != null) {
                lock.unlock();
            }
            // Execution has finished so notify any failover thread that may be waiting for us to be done
            inCreateSession = false;
            inCreateSessionLatch.countDown();
        }
    } while (retry);
    return newSessionContext(name, confirmationWindowSize, sessionChannel, response);
}