destinationsLock.readLock().unlock(); super.removeConsumer(context, sub.getConsumerInfo()); super.addConsumer(context, info); sub = durableSubscriptions.get(key); } else { super.addConsumer(context, info); sub = durableSubscriptions.get(key); if (sub == null) { return sub; } else { return super.addConsumer(context, info);
validateMaxDestinations(destination); dest = createDestination(context, destination); addSubscriptionsForDestination(context, dest); destinations.put(destination, dest); updateRegionDestCounts(destination, 1); destinationMap.unsynchronizedPut(destination, dest);
if (destination != null && !destination.isPattern() && !destination.isComposite()) { lookup(context, destination,true); Subscription sub = createSubscription(context, info);
Destination dest = destinations.remove(destination); if (dest != null) { updateRegionDestCounts(destination, -1); ((Queue) dest).purge(); dispose(context, dest); DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); if (destinationInterceptor != null) {
@Override protected Set<ActiveMQDestination> getInactiveDestinations() { Set<ActiveMQDestination> inactiveDestinations = super.getInactiveDestinations(); for (Iterator<ActiveMQDestination> iter = inactiveDestinations.iterator(); iter.hasNext();) { ActiveMQDestination dest = iter.next(); if (!dest.isTopic()) { iter.remove(); } } return inactiveDestinations; }
@Override public void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control) { Subscription sub = subscriptions.get(control.getConsumerId()); if (sub != null && sub instanceof AbstractSubscription) { ((AbstractSubscription) sub).setPrefetchSize(control.getPrefetch()); if (broker.getDestinationPolicy() != null) { PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(control.getDestination()); if (entry != null) { entry.configurePrefetch(sub); } } LOG.debug("setting prefetch: {}, on subscription: {}; resulting value: {}", new Object[]{ control.getPrefetch(), control.getConsumerId(), sub.getConsumerInfo().getPrefetchSize()}); try { lookup(consumerExchange.getConnectionContext(), control.getDestination(),false).wakeup(); } catch (Exception e) { LOG.warn("failed to deliver post consumerControl dispatch-wakeup, to destination: {}", control.getDestination(), e); } } }
protected final Collection<Subscription> getRegionSubscriptions(ActiveMQDestination dest) { RegionBroker region_broker = (RegionBroker) brokerService.getRegionBroker(); Region region; Collection<Subscription> subs; region = null; switch (dest.getDestinationType()) { case ActiveMQDestination.QUEUE_TYPE: region = region_broker.getQueueRegion(); break; case ActiveMQDestination.TOPIC_TYPE: region = region_broker.getTopicRegion(); break; case ActiveMQDestination.TEMP_QUEUE_TYPE: region = region_broker.getTempQueueRegion(); break; case ActiveMQDestination.TEMP_TOPIC_TYPE: region = region_broker.getTempTopicRegion(); break; } if (region instanceof AbstractRegion) { subs = ((AbstractRegion) region).getSubscriptions().values(); } else { subs = null; } return subs; }
public Destination addDestination(ConnectionContext context, ActiveMQDestination destination, boolean createIfTemporary) throws Exception { LOG.debug(broker.getBrokerName() + " adding destination: " + destination); synchronized (destinationsMutex) { Destination dest = destinations.get(destination); if (dest == null) { if (destination.isTemporary() == false || createIfTemporary) { dest = createDestination(context, destination); // intercept if there is a valid interceptor defined DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); if (destinationInterceptor != null) { dest = destinationInterceptor.intercept(dest); } dest.start(); destinations.put(destination, dest); destinationMap.put(destination, dest); addSubscriptionsForDestination(context, dest); } if (dest == null) { throw new JMSException("The destination " + destination + " does not exist."); } } return dest; } }
@Override @SuppressWarnings("unchecked") public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { LOG.debug("{} removing consumer: {} for destination: {}", new Object[]{ broker.getBrokerName(), info.getConsumerId(), info.getDestination() }); Subscription sub = subscriptions.remove(info.getConsumerId()); // The sub could be removed elsewhere - see ConnectionSplitBroker if (sub != null) { // remove the subscription from all the matching queues. List<Destination> removeList = new ArrayList<Destination>(); destinationsLock.readLock().lock(); try { for (Destination dest : (Set<Destination>) destinationMap.unsynchronizedGet(info.getDestination())) { removeList.add(dest); } } finally { destinationsLock.readLock().unlock(); } for (Destination dest : removeList) { dest.removeSubscription(context, sub, info.getLastDeliveredSequenceId()); } destroySubscription(sub); } synchronized (consumerChangeMutexMap) { consumerChangeMutexMap.remove(info.getConsumerId()); } }
@Override protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception { List<Subscription> rc = super.addSubscriptionsForDestination(context, dest); Set<Subscription> dupChecker = new HashSet<Subscription>(rc);
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; }
protected Destination lookup(ConnectionContext context, ActiveMQDestination destination,boolean createTemporary) throws Exception { Destination dest = null; synchronized (destinationsMutex) { dest = destinations.get(destination); } 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. try { context.getBroker().addDestination(context, destination, createTemporary); dest = addDestination(context, destination, false); } catch (DestinationAlreadyExistsException e) { // if the destination already exists then lets ignore // this error } // We should now have the dest created. synchronized (destinationsMutex) { dest = destinations.get(destination); } } if (dest == null) { throw new JMSException("The destination " + destination + " does not exist."); } } return dest; }
dispose(context, dest); DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); if (destinationInterceptor != null) {
protected Set<ActiveMQDestination> getInactiveDestinations() { Set<ActiveMQDestination> inactiveDestinations = super.getInactiveDestinations(); for (Iterator<ActiveMQDestination> iter = inactiveDestinations.iterator(); iter.hasNext();) { ActiveMQDestination dest = iter.next(); if (!dest.isQueue()) { iter.remove(); } } return inactiveDestinations; }
Destination dest = destinations.remove(destination); if (dest != null) { updateRegionDestCounts(destination, -1); dispose(context, dest); DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); if (destinationInterceptor != null) {
@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 final Collection<Subscription> getRegionSubscriptions(boolean isTopic) { RegionBroker region = (RegionBroker) brokerService.getRegionBroker(); AbstractRegion abstractRegion = (AbstractRegion) (isTopic ? region.getTopicRegion() : region.getQueueRegion()); return abstractRegion.getSubscriptions().values(); }
@Override @SuppressWarnings("unchecked") public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { LOG.debug("{} removing consumer: {} for destination: {}", new Object[]{ broker.getBrokerName(), info.getConsumerId(), info.getDestination() }); Subscription sub = subscriptions.remove(info.getConsumerId()); // The sub could be removed elsewhere - see ConnectionSplitBroker if (sub != null) { // remove the subscription from all the matching queues. List<Destination> removeList = new ArrayList<Destination>(); destinationsLock.readLock().lock(); try { for (Destination dest : (Set<Destination>) destinationMap.unsynchronizedGet(info.getDestination())) { removeList.add(dest); } } finally { destinationsLock.readLock().unlock(); } for (Destination dest : removeList) { dest.removeSubscription(context, sub, info.getLastDeliveredSequenceId()); } destroySubscription(sub); } synchronized (consumerChangeMutexMap) { consumerChangeMutexMap.remove(info.getConsumerId()); } }
@Override protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception { List<Subscription> rc = super.addSubscriptionsForDestination(context, dest); Set<Subscription> dupChecker = new HashSet<Subscription>(rc);
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; }