@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); } }
/** * Re-inject into the Broker chain */ void injectMessage(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception { ProducerBrokerExchange pe = producerExchange; if (pe == null) { pe = new ProducerBrokerExchange(); ConnectionContext cc = new ConnectionContext(); cc.setBroker(this.getRoot()); pe.setConnectionContext(cc); pe.setMutable(true); pe.setProducerState(new ProducerState(new ProducerInfo())); } super.send(pe, messageSend); }
@Test public void testGetPercentageBlockedNonZero(){ ProducerBrokerExchange producerBrokerExchange = new ProducerBrokerExchange(); producerBrokerExchange.blockingOnFlowControl(true); producerBrokerExchange.incrementSend(); assertEquals(100.0, producerBrokerExchange.getPercentageBlocked(), 0); } }
@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; }
@Override public void send(final ProducerBrokerExchange producerExchange, final Message message) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); ProducerState state = producerExchange.getProducerState(); if (state == null) { LOG.warn("Send failed for: {}, missing producer state for: {}", message, producerExchange); throw new JMSException("Cannot send message to " + getActiveMQDestination() + " with invalid (null) producer state"); final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo(); final boolean sendProducerAck = !message.isResponseRequired() && producerInfo.getWindowSize() > 0 && !context.isInRecoveryMode(); final ProducerBrokerExchange producerExchangeCopy = producerExchange.copy(); synchronized (messagesWaitingForSpace) { producerExchange.blockingOnFlowControl(true); if (!context.isNetworkConnection() && systemUsage.getSendFailIfNoSpaceAfterTimeout() != 0) { flowControlTimeoutMessages.add(new TimeoutMessage(message, context, systemUsage
@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);
@Override public void send(final ProducerBrokerExchange producerExchange, final Message message) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo(); producerExchange.incrementSend(); final boolean sendProducerAck = !message.isResponseRequired() && producerInfo.getWindowSize() > 0 && !context.isInRecoveryMode();
@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); }
void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message) throws IOException, Exception { final ConnectionContext context = producerExchange.getConnectionContext(); ListenableFuture<Object> result = null; producerExchange.incrementSend(); pendingSends.incrementAndGet(); do {
public void send(final ProducerBrokerExchange producerExchange, final Message message) throws Exception { final ConnectionContext context = producerExchange.getConnectionContext(); final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo(); final boolean sendProducerAck = !message.isResponseRequired() && producerInfo.getWindowSize() > 0 && !context.isInRecoveryMode(); final ProducerBrokerExchange producerExchangeCopy = producerExchange.copy(); synchronized (messagesWaitingForSpace) {
producerBrokerExchange.blockingOnFlowControl(true); destinationStatistics.getBlockedSends().increment(); while (!usage.waitForSpace(1000, highWaterMark)) { long totalTimeBlocked = finish - start; destinationStatistics.getBlockedTime().addTime(totalTimeBlocked); producerBrokerExchange.incrementTimeBlocked(this,totalTimeBlocked); producerBrokerExchange.blockingOnFlowControl(false);
@Test public void testGetPercentageBlockedHandlesDivideByZero(){ ProducerBrokerExchange producerBrokerExchange = new ProducerBrokerExchange(); producerBrokerExchange.getPercentageBlocked(); }
public ProducerBrokerExchange copy() { ProducerBrokerExchange rc = new ProducerBrokerExchange(); rc.connectionContext = connectionContext.copy(); rc.regionDestination = regionDestination; rc.region = region; rc.producerState = producerState; rc.mutable = mutable; rc.flowControlInfo = flowControlInfo; return rc; }
@Override public Response processMessage(Message messageSend) throws Exception { ProducerId producerId = messageSend.getProducerId(); ProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId); if (producerExchange.canDispatch(messageSend)) { broker.send(producerExchange, messageSend); } return null; }
@Override public void run() { try { if (exceptionAtomicReference.get() == null) { doForward(context.copy(), message, brokerService.getRegionBroker(), destination); } } catch (Exception e) { exceptionAtomicReference.set(e); } finally { concurrent.countDown(); } } });
@Override public int getPercentageBlocked() { ProducerBrokerExchange producerBrokerExchange = broker.getBrokerService().getProducerBrokerExchange(info); if (producerBrokerExchange != null){ return producerBrokerExchange.getPercentageBlocked(); } return 0; }
producerExchangeCopy.blockingOnFlowControl(false);
protected void inject(ProducerBrokerExchange producerBrokerExchange, Message message) throws Exception { ProducerBrokerExchange pbe = producerBrokerExchange; if (message != null) { message.setDestination(destination); if (producerBrokerExchange != null && producerBrokerExchange.getRegionDestination() != null){ if (!producerBrokerExchange.getRegionDestination().getActiveMQDestination().equals(destination)){ //The message broker will create a new ProducerBrokerExchange with the //correct region broker set pbe = null; } } messageInterceptorRegistry.injectMessage(pbe, message); } } }
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); }