@Override public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception { String clientId = info.getClientId(); if (clientId == null) { throw new InvalidClientIDException("No clientID specified for connection disconnect request"); } synchronized (clientIdSet) { ConnectionContext oldValue = clientIdSet.get(clientId); // we may be removing the duplicate connection, not the first connection to be created // so lets check that their connection IDs are the same if (oldValue == context) { if (isEqual(oldValue.getConnectionId(), info.getConnectionId())) { clientIdSet.remove(clientId); } } } connections.remove(context.getConnection()); }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ @Override public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ @Override public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }
} else { throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + oldContext.getConnection().getRemoteAddress()); if (oldContext.getConnection() != null) { Connection connection = oldContext.getConnection(); LOG.warn("Stealing link for clientId {} From Connection {}", clientId, oldContext.getConnection()); if (connection instanceof TransportConnection) { TransportConnection transportConnection = (TransportConnection) connection; transportConnection.stopAsync(new IOException("Stealing link for clientId " + clientId + " From Connection " + oldContext.getConnection().getConnectionId())); } else { connection.stop(); connections.add(context.getConnection());
/** * Occurs when a pull times out. If nothing has been dispatched since the * timeout was setup, then send the NULL message. */ final void pullTimeout(long dispatchCounterBeforePull, boolean alwaysSignalDone) { synchronized (pendingLock) { if (dispatchCounterBeforePull == getSubscriptionStatistics().getDispatched().getCount() || alwaysSignalDone) { try { prefetchExtension.set(1); add(QueueMessageReference.NULL_MESSAGE); dispatchPending(); } catch (Exception e) { context.getConnection().serviceException(e); } finally { prefetchExtension.set(0); } } } }
/** * Occurs when a pull times out. If nothing has been dispatched since the * timeout was setup, then send the NULL message. */ private final void pullTimeout(long currentDispatchedCount, boolean alwaysSendDone) { synchronized (matchedListMutex) { if (currentDispatchedCount == getSubscriptionStatistics().getDispatched().getCount() || alwaysSendDone) { try { dispatch(null); } catch (Exception e) { context.getConnection().serviceException(e); } finally { prefetchExtension.set(0); } } } }
Connection connection = connectionContext.getConnection(); if (connection == null) { LOG.debug("slowConsumer abort ignored, no connection in context:" + connectionContext);
context.getConnection().dispatchAsync(md); } else { context.getConnection().dispatchSync(md); onDispatch(node, message);
@Override public void run() { try { // While waiting for space to free up... the // message may have expired. if (message.isExpired()) { broker.messageExpired(context, message, null); getDestinationStatistics().getExpired().increment(); } else { doMessageSend(producerExchange, message); } if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } catch (Exception e) { if (!sendProducerAck && !context.isInRecoveryMode()) { ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } } });
@Override public void run() { TimeoutMessage timeout; try { while (true) { timeout = flowControlTimeoutMessages.take(); if (timeout != null) { synchronized (messagesWaitingForSpace) { if (messagesWaitingForSpace.remove(timeout.message.getMessageId()) != null) { ExceptionResponse response = new ExceptionResponse( new ResourceAllocationException( "Usage Manager Memory Limit Wait Timeout. Stopping producer (" + timeout.message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info")); response.setCorrelationId(timeout.message.getCommandId()); timeout.context.getConnection().dispatchAsync(response); } } } } } catch (InterruptedException e) { LOG.debug(getName() + "Producer Flow Control Timeout Task is stopping"); } } }
protected void onDispatch(final MessageReference node, final Message message) { Destination nodeDest = (Destination) node.getRegionDestination(); if (nodeDest != null) { if (node != QueueMessageReference.NULL_MESSAGE) { nodeDest.getDestinationStatistics().getDispatched().increment(); nodeDest.getDestinationStatistics().getInflight().increment(); LOG.trace("{} dispatched: {} - {}, dispatched: {}, inflight: {}", new Object[]{ info.getConsumerId(), message.getMessageId(), message.getDestination(), getSubscriptionStatistics().getDispatched().getCount(), dispatched.size() }); } } if (info.isDispatchAsync()) { try { dispatchPending(); } catch (IOException e) { context.getConnection().serviceExceptionAsync(e); } } }
ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } else { LOG.debug("unexpected exception on deferred send of: {}", message, e);
context.getConnection().dispatchAsync(md); } else { context.getConnection().dispatchSync(md); if (node != null) { Destination regionDestination = (Destination) node.getRegionDestination();
if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); context.getConnection().dispatchAsync(ack); if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); context.getConnection().dispatchAsync(ack);
if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); context.getConnection().dispatchAsync(ack); if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); context.getConnection().dispatchAsync(ack);
protected boolean isSystemConnection(ConnectionReference conn) { String remoteAddress = conn.getConnectionContext().getConnection().getRemoteAddress(); return remoteAddress.startsWith("vm:"); }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ @Override public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ @Override public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }
/** * inform the MessageConsumer on the client to change it's prefetch * * @param newPrefetch */ public void updateConsumerPrefetch(int newPrefetch) { if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { ConsumerControl cc = new ConsumerControl(); cc.setConsumerId(info.getConsumerId()); cc.setPrefetch(newPrefetch); context.getConnection().dispatchAsync(cc); } }