LOG.debug("{} removing destination: {}", broker.getBrokerName(), destination); DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); if (destinationInterceptor != null) { destinationInterceptor.remove(dest);
protected void configureTopic(Topic topic, ActiveMQDestination destination) { if (broker.getDestinationPolicy() != null) { PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination); if (entry != null) { entry.configure(broker,topic); } } }
final Set<Destination> virtualDests = regionBroker.getDestinations(virtualDestination); copy.setDestination(newDestination); if (regionDest == null) { regionDest = getBaseDestination((Destination) regionBroker.getDestinations(newDestination).toArray()[0]);
public RegionBroker(BrokerService brokerService, TaskRunnerFactory taskRunnerFactory, SystemUsage memoryManager, DestinationFactory destinationFactory, DestinationInterceptor destinationInterceptor, Scheduler scheduler, ThreadPoolExecutor executor) throws IOException { this.brokerService = brokerService; this.executor = executor; this.scheduler = scheduler; if (destinationFactory == null) { throw new IllegalArgumentException("null destinationFactory"); } this.sequenceGenerator.setLastSequenceId(destinationFactory.getLastMessageBrokerSequenceId()); this.destinationFactory = destinationFactory; queueRegion = createQueueRegion(memoryManager, taskRunnerFactory, destinationFactory); topicRegion = createTopicRegion(memoryManager, taskRunnerFactory, destinationFactory); this.destinationInterceptor = destinationInterceptor; tempQueueRegion = createTempQueueRegion(memoryManager, taskRunnerFactory, destinationFactory); tempTopicRegion = createTempTopicRegion(memoryManager, taskRunnerFactory, destinationFactory); this.taskRunnerFactory = taskRunnerFactory; }
@Override public Map<ActiveMQDestination, Destination> getDestinationMap() { Map<ActiveMQDestination, Destination> answer = new HashMap<ActiveMQDestination, Destination>(getQueueRegion().getDestinationMap()); answer.putAll(getTopicRegion().getDestinationMap()); return answer; }
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; }
protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws IOException { RegionBroker regionBroker; if (isUseJmx()) { try { regionBroker = new ManagedRegionBroker(this, getManagementContext(), getBrokerObjectName(), getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, destinationInterceptor,getScheduler(),getExecutor()); } catch(MalformedObjectNameException me){ LOG.warn("Cannot create ManagedRegionBroker due " + me.getMessage(), me); throw new IOException(me); } } else { regionBroker = new RegionBroker(this, getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, destinationInterceptor,getScheduler(),getExecutor()); } destinationFactory.setRegionBroker(regionBroker); regionBroker.setKeepDurableSubsActive(keepDurableSubsActive); regionBroker.setBrokerName(getBrokerName()); regionBroker.getDestinationStatistics().setEnabled(enableStatistics); regionBroker.setAllowTempAutoCreationOnSend(isAllowTempAutoCreationOnSend()); if (brokerId != null) { regionBroker.setBrokerId(brokerId); } return regionBroker; }
@Override public synchronized void addBroker(Connection connection, BrokerInfo info) { BrokerInfo existing = brokerInfos.get(info.getBrokerId()); if (existing == null) { existing = info.copy(); existing.setPeerBrokerInfos(null); brokerInfos.put(info.getBrokerId(), existing); } existing.incrementRefCount(); LOG.debug("{} addBroker: {} brokerInfo size: {}", new Object[]{ getBrokerName(), info.getBrokerName(), brokerInfos.size() }); addBrokerInClusterUpdate(info); }
@Override public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception { SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName()); RegionBroker regionBroker = null; if (next instanceof RegionBroker) { regionBroker = (RegionBroker) next; } else { BrokerService service = next.getBrokerService(); regionBroker = (RegionBroker) service.getRegionBroker(); } if (regionBroker == null) { LOG.warn("Cannot locate a RegionBroker instance to pass along the removeSubscription call"); throw new IllegalStateException("No RegionBroker found."); } DurableTopicSubscription sub = ((TopicRegion) regionBroker.getTopicRegion()).getDurableSubscription(key); super.removeSubscription(context, info); if (sub == null) { LOG.warn("We cannot send an advisory message for a durable sub removal when we don't know about the durable sub"); return; } ActiveMQDestination dest = sub.getConsumerInfo().getDestination(); // Don't advise advisory topics. if (!AdvisorySupport.isAdvisoryTopic(dest)) { ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest); fireConsumerAdvisory(context, dest, topic, info); } }
dlqExpiration += System.currentTimeMillis(); } else { stampAsExpired(message); adminContext = BrokerSupport.getConnectionContext(this); addDestination(adminContext, deadLetterDestination, false).getActiveMQDestination().setDLQ(true); BrokerSupport.resendNoCopy(adminContext, message, deadLetterDestination); return true;
@Override public void reapplyInterceptor() { destinationsLock.writeLock().lock(); try { DestinationInterceptor destinationInterceptor = broker.getDestinationInterceptor(); Map<ActiveMQDestination, Destination> map = getDestinationMap(); for (ActiveMQDestination key : map.keySet()) { Destination destination = map.get(key); if (destination instanceof CompositeDestinationFilter) { destination = ((CompositeDestinationFilter) destination).next; } if (destinationInterceptor != null) { destination = destinationInterceptor.intercept(destination); } getDestinationMap().put(key, destination); Destination prev = destinations.put(key, destination); if (prev == null) { updateRegionDestCounts(key, 1); } } } finally { destinationsLock.writeLock().unlock(); } } }
public void removeAdvisoryTopics(String destinationType, ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception { if (this.brokerService.isAdvisorySupport()) { String producerAdvisoryTopic = AdvisorySupport.PRODUCER_ADVISORY_TOPIC_PREFIX + destinationType + destination.getPhysicalName(); String consumerAdvisoryTopic = AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + destinationType + destination.getPhysicalName(); ActiveMQDestination dests[] = getDestinations(); for (ActiveMQDestination dest: dests) { String name = dest.getPhysicalName(); if ( name.equals(producerAdvisoryTopic) || name.equals(consumerAdvisoryTopic) ) { try { removeDestination(context, dest, timeout); } catch (JMSException ignore) { // at least ignore the Unknown Destination Type JMSException } } } } }
PolicyEntry updatedEntry, Set<String> includedProperties) { RegionBroker regionBroker = (RegionBroker) runtimeBroker.getBrokerService().getRegionBroker(); for (Destination destination : regionBroker.getDestinations(updatedEntry.getDestination())) { PolicyEntry specificyPolicy = regionBroker.getDestinationPolicy().getEntryFor( destination.getActiveMQDestination());
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription sub = super.addConsumer(context, info); SubscriptionKey subscriptionKey = new SubscriptionKey(sub.getContext().getClientId(), sub.getConsumerInfo().getSubscriptionName()); ObjectName inactiveName = subscriptionKeys.get(subscriptionKey); if (inactiveName != null) { // if it was inactive, register it registerSubscription(context, sub); } return sub; }
@Override public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { addDestination(context, info.getDestination(), true); }
List<ActiveMQQueue> lookupQueues(String clientId) throws MQTTProtocolException { List<ActiveMQQueue> result = new ArrayList<ActiveMQQueue>(); RegionBroker regionBroker; try { regionBroker = (RegionBroker) brokerService.getBroker().getAdaptor(RegionBroker.class); } catch (Exception e) { throw new MQTTProtocolException("Error recovering queues: " + e.getMessage(), false, e); } final QueueRegion queueRegion = (QueueRegion) regionBroker.getQueueRegion(); for (ActiveMQDestination destination : queueRegion.getDestinationMap().keySet()) { if (destination.isQueue() && !destination.isTemporary()) { if (destination.getPhysicalName().startsWith("Consumer." + clientId + ":")) { LOG.debug("Recovered client sub: {} on connect", destination.getPhysicalName()); result.add((ActiveMQQueue) destination); } } } return result; } }
.getDestinationInterceptor()) .setInterceptors(destinationInterceptors); plugin.info("applied new: " + interceptorsList); regionBroker.reapplyInterceptor();
protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws IOException { RegionBroker regionBroker; if (isUseJmx()) { try { regionBroker = new ManagedRegionBroker(this, getManagementContext(), getBrokerObjectName(), getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, destinationInterceptor,getScheduler(),getExecutor()); } catch(MalformedObjectNameException me){ LOG.warn("Cannot create ManagedRegionBroker due " + me.getMessage(), me); throw new IOException(me); } } else { regionBroker = new RegionBroker(this, getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, destinationInterceptor,getScheduler(),getExecutor()); } destinationFactory.setRegionBroker(regionBroker); regionBroker.setKeepDurableSubsActive(keepDurableSubsActive); regionBroker.setBrokerName(getBrokerName()); regionBroker.getDestinationStatistics().setEnabled(enableStatistics); regionBroker.setAllowTempAutoCreationOnSend(isAllowTempAutoCreationOnSend()); if (brokerId != null) { regionBroker.setBrokerId(brokerId); } return regionBroker; }
public RegionBroker(BrokerService brokerService, TaskRunnerFactory taskRunnerFactory, SystemUsage memoryManager, DestinationFactory destinationFactory, DestinationInterceptor destinationInterceptor, Scheduler scheduler, ThreadPoolExecutor executor) throws IOException { this.brokerService = brokerService; this.executor = executor; this.scheduler = scheduler; if (destinationFactory == null) { throw new IllegalArgumentException("null destinationFactory"); } this.sequenceGenerator.setLastSequenceId(destinationFactory.getLastMessageBrokerSequenceId()); this.destinationFactory = destinationFactory; queueRegion = createQueueRegion(memoryManager, taskRunnerFactory, destinationFactory); topicRegion = createTopicRegion(memoryManager, taskRunnerFactory, destinationFactory); this.destinationInterceptor = destinationInterceptor; tempQueueRegion = createTempQueueRegion(memoryManager, taskRunnerFactory, destinationFactory); tempTopicRegion = createTempTopicRegion(memoryManager, taskRunnerFactory, destinationFactory); }
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; }