Search in sources :

Example 1 with AMQPSession

use of org.apache.qpid.server.session.AMQPSession in project qpid-broker-j by apache.

the class BrokerTestHelper method createSession.

public static AMQPSession<?, ?> createSession(int channelId, AMQPConnection<?> connection) {
    @SuppressWarnings("rawtypes") AMQPSession session = mock(AMQPSession.class);
    when(session.getAMQPConnection()).thenReturn(connection);
    when(session.getChannelId()).thenReturn(channelId);
    return session;
}
Also used : AMQPSession(org.apache.qpid.server.session.AMQPSession)

Example 2 with AMQPSession

use of org.apache.qpid.server.session.AMQPSession in project qpid-broker-j by apache.

the class AbstractQueue method switchToConnectionExclusivity.

private void switchToConnectionExclusivity() throws ExistingConsumerPreventsExclusive {
    switch(_exclusive) {
        case NONE:
        case CONTAINER:
        case PRINCIPAL:
            AMQPConnection con = null;
            Iterator<QueueConsumer<?, ?>> queueConsumerIterator = _queueConsumerManager.getAllIterator();
            while (queueConsumerIterator.hasNext()) {
                QueueConsumer<?, ?> c = queueConsumerIterator.next();
                if (con == null) {
                    con = c.getSession().getAMQPConnection();
                } else if (!con.equals(c.getSession().getAMQPConnection())) {
                    throw new ExistingConsumerPreventsExclusive();
                }
            }
            _exclusiveOwner = con;
            break;
        case SESSION:
            _exclusiveOwner = _exclusiveOwner == null ? null : ((AMQPSession<?, ?>) _exclusiveOwner).getAMQPConnection();
            break;
        case LINK:
            _exclusiveOwner = _exclusiveSubscriber == null ? null : _exclusiveSubscriber.getSession().getAMQPConnection();
    }
}
Also used : AMQPConnection(org.apache.qpid.server.transport.AMQPConnection) AMQPSession(org.apache.qpid.server.session.AMQPSession)

Aggregations

AMQPSession (org.apache.qpid.server.session.AMQPSession)2 AMQPConnection (org.apache.qpid.server.transport.AMQPConnection)1