public void setLastStoredSequenceId(long l) { auditProducerSequenceIds = true; if (connectionContext.isNetworkConnection()) { brokerService = connectionContext.getBroker().getBrokerService(); isNetworkProducer = true; } lastSendSequenceNumber.set(l); LOG.debug("last stored sequence id set: {}", l); }
public SelectorAwareVirtualTopicInterceptor(Destination next, VirtualTopic virtualTopic) { super(next, virtualTopic); selectorCachePlugin = (SubQueueSelectorCacheBroker) ((Topic)next).createConnectionContext().getBroker().getAdaptor(SubQueueSelectorCacheBroker.class); }
protected Destination lookup(ConnectionContext context, ActiveMQDestination destination,boolean createTemporary) throws Exception { Destination dest = null; destinationsLock.readLock().lock(); try { dest = destinations.get(destination); } finally { destinationsLock.readLock().unlock(); } if (dest == null) { if (isAutoCreateDestinations()) { // Try to auto create the destination... re-invoke broker // from the // top so that the proper security checks are performed. dest = context.getBroker().addDestination(context, destination, createTemporary); } if (dest == null) { throw new JMSException("The destination " + destination + " does not exist."); } } return dest; }
@Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { ActiveMQDestination destination = info.getDestination(); if (destination != null) { inactiveDestinationsPurgeLock.readLock().lock(); try { // This seems to cause the destination to be added but without // advisories firing... context.getBroker().addDestination(context, destination, isAllowTempAutoCreationOnSend()); getRegion(destination).addProducer(context, info); } finally { inactiveDestinationsPurgeLock.readLock().unlock(); } } }
@Override public final void start() throws Exception { started = true; Set<ActiveMQDestination> inactiveDests = getInactiveDestinations(); for (Iterator<ActiveMQDestination> iter = inactiveDests.iterator(); iter.hasNext();) { ActiveMQDestination dest = iter.next(); ConnectionContext context = new ConnectionContext(); context.setBroker(broker.getBrokerService().getBroker()); context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); context.getBroker().addDestination(context, dest, false); } destinationsLock.readLock().lock(); try{ for (Iterator<Destination> i = destinations.values().iterator(); i.hasNext();) { Destination dest = i.next(); dest.start(); } } finally { destinationsLock.readLock().unlock(); } }
/** * @returns the ObjectName of the Connection that created this subscription */ @Override public ObjectName getConnection() { ObjectName result = null; if (clientId != null && subscription != null) { ConnectionContext ctx = subscription.getContext(); if (ctx != null && ctx.getBroker() != null && ctx.getBroker().getBrokerService() != null) { BrokerService service = ctx.getBroker().getBrokerService(); ManagementContext managementCtx = service.getManagementContext(); if (managementCtx != null) { try { ObjectName query = createConnectionQuery(managementCtx, service.getBrokerName()); Set<ObjectName> names = managementCtx.queryNames(query, null); if (names.size() == 1) { result = names.iterator().next(); } } catch (Exception e) { } } } } return result; }
private void commit(LocalTransactionId tx, ConnectionContext connectionContext, Message message) throws Exception { if (tx != null) { connectionContext.getBroker().commitTransaction(connectionContext, tx, true); connectionContext.getTransactions().remove(tx); connectionContext.setTransaction(null); message.setTransactionId(null); } }
/** * 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) {
@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();
if (sub == null) { ConnectionContext c = new ConnectionContext(); c.setBroker(context.getBroker()); c.setClientId(key.getClientId()); c.setConnectionId(consumerInfo.getConsumerId().getParentId().getParentId());
private LocalTransactionId beginLocalTransaction(int numDestinations, ConnectionContext connectionContext, Message message) throws Exception { LocalTransactionId result = null; if (transactedSend && numDestinations > 1 && message.isPersistent() && message.getTransactionId() == null) { result = new LocalTransactionId(new ConnectionId(message.getMessageId().getProducerId().toString()), message.getMessageId().getProducerSequenceId()); connectionContext.getBroker().beginTransaction(connectionContext, result); connectionContext.setTransaction(connectionContext.getTransactions().get(result)); message.setTransactionId(result); } return result; }
private void scheduleRedelivery(ConnectionContext context, MessageReference messageReference, long delay, int redeliveryCount) throws Exception { if (LOG.isTraceEnabled()) { Destination regionDestination = (Destination) messageReference.getRegionDestination(); LOG.trace("redelivery #{} of: {} with delay: {}, dest: {}", new Object[]{ redeliveryCount, messageReference.getMessageId(), delay, regionDestination.getActiveMQDestination() }); } final Message old = messageReference.getMessage(); Message message = old.copy(); message.setTransactionId(null); message.setMemoryUsage(null); message.removeProperty(ScheduledMessage.AMQ_SCHEDULED_ID); message.setProperty(REDELIVERY_DELAY, delay); message.setProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay); message.setRedeliveryCounter(redeliveryCount); boolean originalFlowControl = context.isProducerFlowControl(); try { context.setProducerFlowControl(false); ProducerInfo info = new ProducerInfo(); ProducerState state = new ProducerState(info); ProducerBrokerExchange producerExchange = new ProducerBrokerExchange(); producerExchange.setProducerState(state); producerExchange.setMutable(true); producerExchange.setConnectionContext(context); context.getBroker().send(producerExchange, message); } finally { context.setProducerFlowControl(originalFlowControl); } }
@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); } }
final RegionBroker regionBroker = (RegionBroker) context.getBroker().getAdaptor(RegionBroker.class); final Set<Destination> virtualDests = regionBroker.getDestinations(virtualDestination);
public static void doResend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination, boolean copy) throws Exception { Message message = copy ? originalMessage.copy() : originalMessage; message.setOriginalDestination(message.getDestination()); message.setOriginalTransactionId(message.getTransactionId()); message.setDestination(deadLetterDestination); message.setTransactionId(null); message.setMemoryUsage(null); message.setRedeliveryCounter(0); message.getMessageId().setDataLocator(null); boolean originalFlowControl = context.isProducerFlowControl(); try { context.setProducerFlowControl(false); ProducerInfo info = new ProducerInfo(); ProducerState state = new ProducerState(info); ProducerBrokerExchange producerExchange = new ProducerBrokerExchange(); producerExchange.setProducerState(state); producerExchange.setMutable(true); producerExchange.setConnectionContext(context); context.getBroker().send(producerExchange, message); } finally { context.setProducerFlowControl(originalFlowControl); } }
producerExchange.setConnectionContext(context); producerExchange.setProducerState(new ProducerState(new ProducerInfo())); context.getBroker().send(producerExchange, message); } finally { context.setProducerFlowControl(originalFlowControl);
public void setLastStoredSequenceId(long l) { auditProducerSequenceIds = true; if (connectionContext.isNetworkConnection()) { brokerService = connectionContext.getBroker().getBrokerService(); isNetworkProducer = true; } lastSendSequenceNumber.set(l); LOG.debug("last stored sequence id set: {}", l); }
public SelectorAwareVirtualTopicInterceptor(Destination next, VirtualTopic virtualTopic) { super(next, virtualTopic); selectorCachePlugin = (SubQueueSelectorCacheBroker) ((Topic)next).createConnectionContext().getBroker().getAdaptor(SubQueueSelectorCacheBroker.class); }
private void commit(LocalTransactionId tx, ConnectionContext connectionContext, Message message) throws Exception { if (tx != null) { connectionContext.getBroker().commitTransaction(connectionContext, tx, true); connectionContext.getTransactions().remove(tx); connectionContext.setTransaction(null); message.setTransactionId(null); } }