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(); } }
private ListenableFuture<Void> doOnIoThreadAsync(final Runnable task) { return getSession().getAMQPConnection().doOnIOThreadAsync(task); }
@Override public boolean verifySessionAccess(final AMQPSession<?,?> session) { boolean allowed; switch(_exclusive) { case NONE: allowed = true; break; case SESSION: allowed = _exclusiveOwner == null || _exclusiveOwner == session; break; case CONNECTION: allowed = _exclusiveOwner == null || _exclusiveOwner == session.getAMQPConnection(); break; case PRINCIPAL: allowed = _exclusiveOwner == null || Objects.equals(((Principal) _exclusiveOwner).getName(), session.getAMQPConnection().getAuthorizedPrincipal().getName()); break; case CONTAINER: allowed = _exclusiveOwner == null || _exclusiveOwner.equals(session.getAMQPConnection().getRemoteContainerName()); break; case LINK: allowed = _exclusiveSubscriber == null || _exclusiveSubscriber.getSession() == session; break; default: throw new ServerScopedRuntimeException("Unknown exclusivity policy " + _exclusive); } return allowed; }
String name = session.getAMQPConnection().getConnectionId() + "|" + session.getChannelId()
if(principal == null) principal = c.getSession().getAMQPConnection().getAuthorizedPrincipal(); c.getSession().getAMQPConnection().getAuthorizedPrincipal().getName())) break; case SESSION: _exclusiveOwner = _exclusiveOwner == null ? null : ((AMQPSession<?,?>)_exclusiveOwner).getAMQPConnection().getAuthorizedPrincipal(); break; case LINK: _exclusiveOwner = _exclusiveSubscriber == null ? null : _exclusiveSubscriber.getSession().getAMQPConnection().getAuthorizedPrincipal();
if(containerID == null) containerID = c.getSession().getAMQPConnection().getRemoteContainerName(); else if(!containerID.equals(c.getSession().getAMQPConnection().getRemoteContainerName())) break; case SESSION: _exclusiveOwner = _exclusiveOwner == null ? null : ((AMQPSession<?,?>)_exclusiveOwner).getAMQPConnection().getRemoteContainerName(); break; case LINK: _exclusiveOwner = _exclusiveSubscriber == null ? null : _exclusiveSubscriber.getSession().getAMQPConnection().getRemoteContainerName();
@Override public boolean processPending() { if (getSession() == null || !getSession().getAMQPConnection().isIOThread()) { return false; } // TODO - if not closed return sendNextMessage(); }
private void switchToSessionExclusivity() throws ExistingConsumerPreventsExclusive { switch(_exclusive) { case NONE: case PRINCIPAL: case CONTAINER: case CONNECTION: AMQPSession<?,?> session = null; Iterator<QueueConsumer<?,?>> queueConsumerIterator = _queueConsumerManager.getAllIterator(); while(queueConsumerIterator.hasNext()) { QueueConsumer<?,?> c = queueConsumerIterator.next(); if(session == null) { session = c.getSession(); } else if(!session.equals(c.getSession())) { throw new ExistingConsumerPreventsExclusive(); } } _exclusiveOwner = session; break; case LINK: _exclusiveOwner = _exclusiveSubscriber == null ? null : _exclusiveSubscriber.getSession().getAMQPConnection(); } }
@Override public final void send(final MessageInstanceConsumer consumer, MessageInstance entry, boolean batch) { doSend(consumer, entry, batch); getSession().getAMQPConnection().updateLastMessageOutboundTime(); if (consumer.acquires()) { entry.makeAcquisitionStealable(); } }
protected String generateSessionMessage(final AMQPSession session) { AMQPConnection<?> connection = session.getAMQPConnection(); return "[" + MessageFormat.format(CHANNEL_FORMAT, connection == null ? -1L : connection.getConnectionId(), (connection == null || connection.getAuthorizedPrincipal() == null) ? "?" : connection.getAuthorizedPrincipal().getName(), (connection == null || connection.getRemoteAddressString() == null) ? "?" : connection.getRemoteAddressString(), (connection == null || connection.getAddressSpaceName() == null) ? "?" : connection.getAddressSpaceName(), session.getChannelId()) + "] "; }
if(exclusiveOwner == null) exclusiveOwner = session.getAMQPConnection(); addExclusivityConstraint(session.getAMQPConnection()); if(exclusiveOwner != session.getAMQPConnection()) Principal currentAuthorizedPrincipal = session.getAMQPConnection().getAuthorizedPrincipal(); if(exclusiveOwner == null) if(exclusiveOwner == null) exclusiveOwner = session.getAMQPConnection().getRemoteContainerName(); if(!exclusiveOwner.equals(session.getAMQPConnection().getRemoteContainerName()))
_exclusiveOwner = session.getAMQPConnection().getAuthorizedPrincipal(); break; case CONTAINER: _exclusiveOwner = session.getAMQPConnection().getRemoteContainerName(); break; case CONNECTION: _exclusiveOwner = session.getAMQPConnection(); addExclusivityConstraint(session.getAMQPConnection()); break; case SESSION: addLifetimeConstraint(session.getAMQPConnection());
public void updateSessionDetails() { /** * LOG FORMAT used by the AMQPConnectorActor follows * ChannelLogSubject.CHANNEL_FORMAT : con:{0}({1}@{2}/{3})/ch:{4}. * * Uses a MessageFormat call to insert the required values according to * these indices: * * 0 - Connection ID * 1 - User ID * 2 - IP * 3 - Virtualhost * 4 - Channel ID */ AMQPConnection connection = _sessionModel.getAMQPConnection(); setLogStringWithFormat(CHANNEL_FORMAT, connection == null ? -1L : connection.getConnectionId(), (connection == null || connection.getAuthorizedPrincipal() == null) ? "?" : connection.getAuthorizedPrincipal().getName(), (connection == null || connection.getRemoteAddressString() == null) ? "?" : connection.getRemoteAddressString(), (connection == null || connection.getAddressSpaceName() == null) ? "?" : connection.getAddressSpaceName(), _sessionModel.getChannelId()); } }