@Override protected void send(final ProducerBrokerExchange context, final Message message, ActiveMQDestination destination) throws Exception { final Broker broker = context.getConnectionContext().getBroker(); final Set<Destination> destinations = broker.getDestinations(destination); final int numDestinations = destinations.size(); beginLocalTransaction(numDestinations, context.getConnectionContext(), message); try { if (concurrentSend && numDestinations > 1) { commit(localBrokerTransactionToCoalesceJournalSync, context.getConnectionContext(), message);
/** * Sends a message to the given destination which may be a wildcard * * @param context broker context * @param message message to send * @param destination possibly wildcard destination to send the message to * @throws Exception on error */ protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination destination) throws Exception { Broker broker = context.getConnectionContext().getBroker(); Set<Destination> destinations = broker.getDestinations(destination); for (Destination dest : destinations) { dest.send(context, message.copy()); } }
final BrokerService brokerService = context.getConnectionContext().getBroker().getBrokerService(); for (final ActiveMQDestination destination : matchingDestinations) { if (concurrent.getCount() > 0) {
private Transaction getActiveTransaction(Command command) { Transaction transaction = null; try { if (command instanceof Message) { Message messageSend = (Message) command; ProducerId producerId = messageSend.getProducerId(); ProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId); transaction = producerExchange.getConnectionContext().getTransactions().get(messageSend.getTransactionId()); } else if (command instanceof MessageAck) { MessageAck messageAck = (MessageAck) command; ConsumerBrokerExchange consumerExchange = getConsumerBrokerExchange(messageAck.getConsumerId()); if (consumerExchange != null) { transaction = consumerExchange.getConnectionContext().getTransactions().get(messageAck.getTransactionId()); } } } catch(Exception ignored){ LOG.trace("failed to find active transaction for command: " + command, ignored); } return transaction; }
public void send(ProducerBrokerExchange producerExchange, final Message message) throws Exception { // This method may be invoked recursively. // Track original tx so that it can be restored. final ConnectionContext context = producerExchange.getConnectionContext(); Transaction originalTx = context.getTransaction(); Transaction transaction = null; if (message.getTransactionId() != null) { transaction = getTransaction(context, message.getTransactionId(), false); } context.setTransaction(transaction); try { next.send(producerExchange, message); } finally { context.setTransaction(originalTx); } }
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); String userID = context.getUserName(); if (isUseAuthenticatePrincipal()) { SecurityContext securityContext = context.getSecurityContext(); if (securityContext != null) { Set<?> principals = securityContext.getPrincipals(); if (principals != null) { for (Object candidate : principals) { if (candidate instanceof UserPrincipal) { userID = ((UserPrincipal)candidate).getName(); break; } } } } } messageSend.setUserID(userID); super.send(producerExchange, messageSend); }
@Override public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { ActiveMQDestination destination = message.getDestination(); message.setBrokerInTime(System.currentTimeMillis()); if (producerExchange.isMutable() || producerExchange.getRegion() == null || (producerExchange.getRegionDestination() != null && producerExchange.getRegionDestination().isDisposed())) { // ensure the destination is registered with the RegionBroker producerExchange.getConnectionContext().getBroker() .addDestination(producerExchange.getConnectionContext(), destination, isAllowTempAutoCreationOnSend()); producerExchange.setRegion(getRegion(destination)); producerExchange.setRegionDestination(null); } producerExchange.getRegion().send(producerExchange, message); // clean up so these references aren't kept (possible leak) in the producer exchange // especially since temps are transitory if (producerExchange.isMutable()) { producerExchange.setRegionDestination(null); producerExchange.setRegion(null); } }
@Override public void send(ProducerBrokerExchange exchange, Message message) throws Exception { if (exchange != null && exchange.getProducerState() != null && exchange.getProducerState().getInfo() != null) { ProducerInfo info = exchange.getProducerState().getInfo(); if (info.getDestination() == null && info.getProducerId() != null) { ObjectName objectName = BrokerMBeanSupport.createProducerName(brokerObjectName, exchange.getConnectionContext().getClientId(), info); ProducerView view = this.dynamicDestinationProducers.get(objectName); if (view != null) { ActiveMQDestination dest = message.getDestination(); if (dest != null) { view.setLastUsedDestinationName(dest); } } } } super.send(exchange, message); }
@Override public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final SecurityContext securityContext = checkSecurityContext(producerExchange.getConnectionContext()); if (!securityContext.isBrokerContext() && !securityContext.getAuthorizedWriteDests().containsValue(messageSend.getDestination())) { Set<?> allowedACLs = null; if (!messageSend.getDestination().isTemporary()) { allowedACLs = authorizationMap.getWriteACLs(messageSend.getDestination()); } else { allowedACLs = authorizationMap.getTempDestinationWriteACLs(); } if (allowedACLs != null && !securityContext.isInOneOf(allowedACLs)) { throw new SecurityException("User " + securityContext.getUserName() + " is not authorized to write to: " + messageSend.getDestination()); } securityContext.getAuthorizedWriteDests().put(messageSend.getDestination(), messageSend.getDestination()); } super.send(producerExchange, messageSend); }
@Override public void send(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception { ConnectionContext context = producerExchange.getConnectionContext(); sendScheduledJob(producerExchange.getConnectionContext(), job, replyTo); sendScheduledJob(producerExchange.getConnectionContext(), job, replyTo);
@Override public void send(final ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); if (producerExchange.isMutable() || producerExchange.getRegionDestination() == null) { final Destination regionDestination = lookup(context, messageSend.getDestination(),false); producerExchange.setRegionDestination(regionDestination); } producerExchange.getRegionDestination().send(producerExchange, messageSend); if (producerExchange.getProducerState() != null && producerExchange.getProducerState().getInfo() != null){ producerExchange.getProducerState().getInfo().incrementSentCount(); } }
private ProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException { ProducerBrokerExchange result = producerExchanges.get(id); if (result == null) { synchronized (producerExchanges) { result = new ProducerBrokerExchange(); TransportConnectionState state = lookupConnectionState(id); context = state.getContext(); result.setConnectionContext(context); if (context.isReconnect() || (context.isNetworkConnection() && connector.isAuditNetworkProducers())) { result.setLastStoredSequenceId(brokerService.getPersistenceAdapter().getLastProducerSequenceId(id)); } SessionState ss = state.getSessionState(id.getParentId()); if (ss != null) { result.setProducerState(ss.getProducerState(id)); ProducerState producerState = ss.getProducerState(id); if (producerState != null && producerState.getInfo() != null) { ProducerInfo info = producerState.getInfo(); result.setMutable(info.getDestination() == null || info.getDestination().isComposite()); } } producerExchanges.put(id, result); } } else { context = result.getConnectionContext(); } return result; }
void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message) throws IOException, Exception { final ConnectionContext context = producerExchange.getConnectionContext(); ListenableFuture<Object> result = null;
final ConnectionContext context = producerExchange.getConnectionContext(); message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); Future<Object> result = null;
statsMessage.setLong("producerCount", stats.getProducers().getCount()); statsMessage.setJMSCorrelationID(messageSend.getCorrelationId()); sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo); ActiveMQMapMessage statsMessage = new ActiveMQMapMessage(); statsMessage.setJMSCorrelationID(messageSend.getCorrelationId()); sendStats(producerExchange.getConnectionContext(),statsMessage,replyTo); sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getQueueSubscribers(), replyTo); sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getTopicSubscribers(), replyTo); } else if (brokerStats) { statsMessage.setString("dataDirectory", answer); statsMessage.setJMSCorrelationID(messageSend.getCorrelationId()); sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo); } else { super.send(producerExchange, messageSend);
@Override public void send(final ProducerBrokerExchange producerExchange, final Message message) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext();
@Override public void send(final ProducerBrokerExchange producerExchange, final Message message) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext();
@Override public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { ConnectionMonitor monitor = monitors.get(producerExchange.getConnectionContext().getConnectionId()); if( monitor!=null ) { monitor.onSend(producerExchange, messageSend); } }
@Override public void send(final ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); if (producerExchange.isMutable() || producerExchange.getRegionDestination() == null) { final Destination regionDestination = lookup(context, messageSend.getDestination(),false); producerExchange.setRegionDestination(regionDestination); } producerExchange.getRegionDestination().send(producerExchange, messageSend); if (producerExchange.getProducerState() != null && producerExchange.getProducerState().getInfo() != null){ producerExchange.getProducerState().getInfo().incrementSentCount(); } }
@Override public void send(final ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); if (producerExchange.isMutable() || producerExchange.getRegionDestination() == null) { final Destination regionDestination = lookup(context, messageSend.getDestination(),false); producerExchange.setRegionDestination(regionDestination); } producerExchange.getRegionDestination().send(producerExchange, messageSend); if (producerExchange.getProducerState() != null && producerExchange.getProducerState().getInfo() != null){ producerExchange.getProducerState().getInfo().incrementSentCount(); } }