@Override public Broker getRoot() { try { return getBrokerService().getBroker(); } catch (Exception e) { LOG.error("Trying to get Root Broker", e); throw new RuntimeException("The broker from the BrokerService should not throw an exception"); } }
public TopicRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); if (broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule() != -1 && broker.getBrokerService().getOfflineDurableSubscriberTimeout() != -1) { this.cleanupTimer = new Timer("ActiveMQ Durable Subscriber Cleanup Timer", true); this.cleanupTask = new TimerTask() { @Override public void run() { doCleanup(); } }; this.cleanupTimer.schedule(cleanupTask, broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule(), broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule()); } }
/** * @param broker * @param destinationStatistics * @param memoryManager * @param taskRunnerFactory * @param destinationFactory */ public AbstractTempRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); this.doCacheTempDestinations=broker.getBrokerService().isCacheTempDestinations(); this.purgeTime = broker.getBrokerService().getTimeBeforePurgeTempDestinations(); if (this.doCacheTempDestinations) { this.purgeTimer = new Timer("ActiveMQ Temp destination purge timer", true); this.purgeTask = new TimerTask() { public void run() { doPurge(); } }; this.purgeTimer.schedule(purgeTask, purgeTime, purgeTime); } }
@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(); } }
public void doCleanup() { long now = System.currentTimeMillis(); for (Map.Entry<SubscriptionKey, DurableTopicSubscription> entry : durableSubscriptions.entrySet()) { DurableTopicSubscription sub = entry.getValue(); if (!sub.isActive()) { long offline = sub.getOfflineTimestamp(); if (offline != -1 && now - offline >= broker.getBrokerService().getOfflineDurableSubscriberTimeout()) { LOG.info("Destroying durable subscriber due to inactivity: {}", sub); try { RemoveSubscriptionInfo info = new RemoveSubscriptionInfo(); info.setClientId(entry.getKey().getClientId()); info.setSubscriptionName(entry.getKey().getSubscriptionName()); ConnectionContext context = new ConnectionContext(); context.setBroker(broker); context.setClientId(entry.getKey().getClientId()); removeSubscription(context, info); } catch (Exception e) { LOG.error("Failed to remove inactive durable subscriber", e); } } } } }
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) throws IOException { if (info1.getSelector() != null ^ info2.getSelector() != null) { return true; } if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { return true; } //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return !info1.getDestination().equals(info2.getDestination()); }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { if (info.isDurable()) { if (broker.getBrokerService().isRejectDurableConsumers()) { throw new JMSException("Durable Consumers are not allowed");
long endTime = System.currentTimeMillis(); message.setBrokerOutTime(endTime); if (getBrokerService().isEnableStatistics()) { long totalTime = endTime - message.getBrokerInTime(); ((Destination) message.getRegionDestination()).getDestinationStatistics().getProcessTime().addTime(totalTime);
@Override public Broker getRoot() { try { return getBrokerService().getBroker(); } catch (Exception e) { LOG.error("Trying to get Root Broker", e); throw new RuntimeException("The broker from the BrokerService should not throw an exception"); } }
@Override public Broker getRoot() { try { return getBrokerService().getBroker(); } catch (Exception e) { LOG.error("Trying to get Root Broker", e); throw new RuntimeException("The broker from the BrokerService should not throw an exception"); } }
@Override public Broker getRoot() { try { return getBrokerService().getBroker(); } catch (Exception e) { LOG.error("Trying to get Root Broker", e); throw new RuntimeException("The broker from the BrokerService should not throw an exception"); } }
@Override public Broker getRoot() { try { return getBrokerService().getBroker(); } catch (Exception e) { LOG.error("Trying to get Root Broker " + e); throw new RuntimeException("The broker from the BrokerService should not throw an exception"); } }
public TopicRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); if (broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule() != -1 && broker.getBrokerService().getOfflineDurableSubscriberTimeout() != -1) { this.cleanupTimer = new Timer("ActiveMQ Durable Subscriber Cleanup Timer", true); this.cleanupTask = new TimerTask() { @Override public void run() { doCleanup(); } }; this.cleanupTimer.schedule(cleanupTask, broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule(), broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule()); } }
public TopicRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); if (broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule() != -1 && broker.getBrokerService().getOfflineDurableSubscriberTimeout() != -1) { this.cleanupTimer = new Timer("ActiveMQ Durable Subscriber Cleanup Timer", true); this.cleanupTask = new TimerTask() { @Override public void run() { doCleanup(); } }; this.cleanupTimer.schedule(cleanupTask, broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule(), broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule()); } }
public TopicRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) { super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory); if (broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule() != -1 && broker.getBrokerService().getOfflineDurableSubscriberTimeout() != -1) { this.cleanupTimer = new Timer("ActiveMQ Durable Subscriber Cleanup Timer", true); this.cleanupTask = new TimerTask() { @Override public void run() { doCleanup(); } }; this.cleanupTimer.schedule(cleanupTask, broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule(), broker.getBrokerService().getOfflineDurableSubscriberTaskSchedule()); } }
@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(); } }
@Override public void preProcessDispatch(MessageDispatch messageDispatch) { Message message = messageDispatch.getMessage(); if (message != null) { long endTime = System.currentTimeMillis(); message.setBrokerOutTime(endTime); if (getBrokerService().isEnableStatistics()) { long totalTime = endTime - message.getBrokerInTime(); message.getRegionDestination().getDestinationStatistics().getProcessTime().addTime(totalTime); } } }
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) throws IOException { if (info1.getSelector() != null ^ info2.getSelector() != null) { return true; } if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { return true; } //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return !info1.getDestination().equals(info2.getDestination()); }
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) throws IOException { if (info1.getSelector() != null ^ info2.getSelector() != null) { return true; } if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { return true; } //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return !info1.getDestination().equals(info2.getDestination()); }
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) throws IOException { if (info1.getSelector() != null ^ info2.getSelector() != null) { return true; } if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { return true; } //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return !info1.getDestination().equals(info2.getDestination()); }