} else { throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + oldContext.getConnection().getRemoteAddress()); 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();
context.getConnection().dispatchAsync(md); } else { context.getConnection().dispatchSync(md); onDispatch(node, message);
/** * Resets the statistics */ @Override public void resetStatistics() { connection.getStatistics().reset(); }
/** * 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); } }
connection.getConnectionId(), subscriptions.size()); new Object[] { connection.getConnectionId(), subscription.getConsumerInfo().getConsumerId(), subscription.getActiveMQDestination() }); } catch (Exception e) { LOG.info("exception on aborting connection {} with {} slow consumers", connection.getConnectionId(), subscriptions.size()); stopConsumer.setConsumerId(subscription.getConsumerInfo().getConsumerId()); stopConsumer.setClose(true); connection.dispatchAsync(stopConsumer); } catch (Exception e) { LOG.info("exception on aborting slow consumer: {}", subscription.getConsumerInfo().getConsumerId(), e);
public String getConnectionId() { return connection.getConnectionId(); }
@Override public String getRemoteAddress() { return connection.getRemoteAddress(); }
/** * start processing this broker */ public void startProcessing() { started.set(true); try { Connection[] connections = getClients(); ConnectionControl command = new ConnectionControl(); command.setFaultTolerant(true); if (connections != null) { for (int i = 0; i < connections.length; i++) { if (connections[i].isActive() && connections[i].isManageable()) { connections[i].dispatchAsync(command); } } } } catch (Exception e) { LOG.error("Failed to get Connections", e); } }
@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); } } } });
logger.debug("Checking if {} equals {}", kcc.getFullClientId(), conn.getConnectionId()); if (kcc.getFullClientId().equals(conn.getConnectionId())) { conn.serviceExceptionAsync(new IOException(new KapuaDuplicateClientIdException(kcc.getFullClientId())));
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); } } }
/** * @return if after being marked, the Connection is still writing */ @Override public boolean isBlocked() { return connection.isBlocked(); }
/** * @return true if the Connection is active */ @Override public boolean isActive() { return connection.isActive(); }
/** * @return true if the Connection is connected */ @Override public boolean isConnected() { return connection.isConnected(); }
public boolean handleUser(boolean addition, URI user, URI defaultRole, URI defaultAclTemplate, String userId,String password) throws BocaException { SecurityContext sc = userSecurityContextMap.get(user.toString()); if (sc != null) { if (!addition) { Set<ConnectionContext> conns = userConnection.get(sc.getUserName()); if (conns != null) { for (Iterator<ConnectionContext> iter = conns.iterator(); iter.hasNext();) { ConnectionContext con = iter.next(); try { ConnectionError cmd = new ConnectionError(); cmd.setException(new Exception("user removed")); con.getConnection().dispatchSync(cmd); } catch (Exception e) { } if (securityContexts.remove(con.getSecurityContext())) { con.setSecurityContext(null); } } } } else { sc.getAuthorizedReadDests().clear(); sc.getAuthorizedWriteDests().clear(); } } return true; }
@Override public String getClientId() { return connection.getConnectionId(); }
/** * 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); } }
@Override public String getRemoteAddress() { return connection.getRemoteAddress(); }
@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"); } } }
connection.getConnectionId(), subscriptions.size()); new Object[] { connection.getConnectionId(), subscription.getConsumerInfo().getConsumerId(), subscription.getActiveMQDestination() }); } catch (Exception e) { LOG.info("exception on aborting connection {} with {} slow consumers", connection.getConnectionId(), subscriptions.size()); stopConsumer.setConsumerId(subscription.getConsumerInfo().getConsumerId()); stopConsumer.setClose(true); connection.dispatchAsync(stopConsumer); } catch (Exception e) { LOG.info("exception on aborting slow consumer: {}", subscription.getConsumerInfo().getConsumerId(), e);