@Override public void run() { _sessionIterator.remove(); if (session.processPending()) { _sessionsWithPending.add(session); } } };
@Override public void childRemoved(final ConfiguredObject<?> object, final ConfiguredObject<?> child) { if (child.equals(consumer)) { session.consumerRemoved(consumer); removeChangeListener(this); } } });
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(); } }
String name = session.getAMQPConnection().getConnectionId() + "|" + session.getChannelId() + "|" + linkName;
protected final void setNotifyWorkDesired(final boolean desired) { if (desired != _notifyWorkDesired) { if (desired) { getSession().removeTicker(_suspendedConsumerLoggingTicker); } else { _suspendedConsumerLoggingTicker.setStartTime(System.currentTimeMillis()); getSession().addTicker(_suspendedConsumerLoggingTicker); } for (MessageInstanceConsumer consumer : _consumers) { consumer.setNotifyWorkDesired(desired); } _notifyWorkDesired = desired; } }
@Override public void performAction(final AMQPConnection_0_8Impl object) { int channelId = session.getChannelId(); closeChannel(channelId, cause, message); MethodRegistry methodRegistry = getMethodRegistry(); ChannelCloseBody responseBody = methodRegistry.createChannelCloseBody( cause, AMQShortString.validValueOf(message), 0, 0); writeFrame(responseBody.generateFrame(channelId)); } });
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())) consumer.addChangeListener(_deletedChildListener); session.consumerAdded(consumer); addChangeListener(new AbstractConfigurationChangeListener()
@Override public boolean matches(Filterable message) { final Collection<QueueConsumer<?,?>> consumers = _queue.getConsumers(); for(QueueConsumer<?,?> c : consumers) { if(c.getSession().getConnectionReference() == message.getConnectionReference()) { return false; } } return !consumers.isEmpty(); }
@Override public String getName() { return "session:"+_session.getId(); }
private void checkOverfull(final long maximumQueueDepthBytes, final long maximumQueueDepthMessages) { final long queueDepthBytes = _queue.getQueueDepthBytes(); final long queueDepthMessages = _queue.getQueueDepthMessages(); if ((maximumQueueDepthBytes >= 0L && queueDepthBytes > maximumQueueDepthBytes) || (maximumQueueDepthMessages >= 0L && queueDepthMessages > maximumQueueDepthMessages)) { Subject subject = Subject.getSubject(AccessController.getContext()); Set<SessionPrincipal> sessionPrincipals = subject.getPrincipals(SessionPrincipal.class); if (!sessionPrincipals.isEmpty()) { SessionPrincipal sessionPrincipal = sessionPrincipals.iterator().next(); if (sessionPrincipal != null) { if (_overfullReported.compareAndSet(false, true)) { _eventLogger.message(_queue.getLogSubject(), QueueMessages.OVERFULL(queueDepthBytes, maximumQueueDepthBytes, queueDepthMessages, maximumQueueDepthMessages)); } final AMQPSession<?, ?> session = sessionPrincipal.getSession(); _blockedSessions.add(session); session.block(_queue); } } } }
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()) + "] "; }
QueueConsumerImpl(final AbstractQueue<?> queue, T target, final String consumerName, final FilterManager filters, final Class<? extends ServerMessage> messageClass, EnumSet<ConsumerOption> optionSet, final Integer priority) { super(queue, createAttributeMap(target.getSession(), consumerName, filters, optionSet, priority)); _messageClass = messageClass; _sessionReference = target.getSession().getConnectionReference(); _consumerNumber = CONSUMER_NUMBER_GENERATOR.getAndIncrement(); _filters = filters; _acquires = optionSet.contains(ConsumerOption.ACQUIRES); _seesRequeues = optionSet.contains(ConsumerOption.SEES_REQUEUES); _isTransient = optionSet.contains(ConsumerOption.TRANSIENT); _target = target; _queue = queue; _linkName = consumerName; // Access control authorise(Operation.CREATE); open(); setupLogging(); }
@Override public void run() { _sessionIterator.remove(); if (session.processPending()) { _sessionsWithWork.add(session); } } };
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()); } }
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; }
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(); }