@Override public void slowConsumer(ConnectionContext context, Subscription subs) { if (maxSlowCount < 0 && maxSlowDuration < 0) { // nothing to do LOG.info("no limits set, slowConsumer strategy has nothing to do"); return; } if (taskStarted.compareAndSet(false, true)) { scheduler.executePeriodically(this, checkPeriod); } if (!slowConsumers.containsKey(subs)) { slowConsumers.put(subs, new SlowConsumerEntry(context)); } else if (maxSlowCount > 0) { slowConsumers.get(subs).slow(); } }
@Override public synchronized void start() throws Exception { if (!started.compareAndSet(false, true)) { return; wireFormat.setVersion(brokerService.getStoreOpenWireVersion()); this.usageManager.getMemoryUsage().addUsageListener(this); this.scheduler = new Scheduler("Journal Scheduler"); this.scheduler.start(); this.scheduler.executePeriodically(periodicCheckpointTask, checkpointInterval / 10);
@Override public void stop() throws Exception { this.usageManager.getMemoryUsage().removeUsageListener(this); if (!started.compareAndSet(true, false)) { return; } this.scheduler.cancel(periodicCheckpointTask); this.scheduler.stop(); // Take one final checkpoint and stop checkpoint processing. checkpoint(true, true); checkpointTask.shutdown(); ThreadPoolUtils.shutdown(checkpointExecutor); checkpointExecutor = null; queues.clear(); topics.clear(); IOException firstException = null; try { journal.close(); } catch (Exception e) { firstException = IOExceptionSupport.create("Failed to close journals: " + e, e); } longTermPersistence.stop(); if (firstException != null) { throw firstException; } }
public synchronized Scheduler getScheduler() { if (this.scheduler==null) { this.scheduler = new Scheduler("ActiveMQ Broker["+getBrokerName()+"] Scheduler"); try { this.scheduler.start(); } catch (Exception e) { LOG.error("Failed to start Scheduler", e); } } return this.scheduler; }
this.session.connection.getScheduler().cancel(optimizedAckTask); } catch (JMSException e) { LOG.debug("Caught exception while cancelling old optimized ack task", e); this.session.connection.getScheduler().executePeriodically(optimizedAckTask, optimizedAckScheduledAckInterval); } catch (JMSException e) { LOG.debug("Caught exception while scheduling new optimized ack task", e);
protected Scheduler getScheduler() throws JMSException { Scheduler result = scheduler; if (result == null) { if (isClosing() || isClosed()) { // without lock contention report the closing state throw new ConnectionClosedException(); } synchronized (this) { result = scheduler; if (result == null) { checkClosed(); try { result = new Scheduler("ActiveMQConnection["+info.getConnectionId().getValue()+"] Scheduler"); result.start(); scheduler = result; } catch(Exception e) { throw JMSExceptionSupport.create(e); } } } } return result; }
if (preShutdownHooksInvoked.compareAndSet(false, true)) { for (Runnable hook : preShutdownHooks) { try { if (!stopping.compareAndSet(false, true)) { LOG.trace("Broker already stopping/stopped"); return; setStartException(new BrokerStoppedException("Stop invoked")); MDC.put("activemq.broker", brokerName); LOG.info("Apache ActiveMQ {} ({}, {}) is shutting down", new Object[]{ getBrokerVersion(), getBrokerName(), brokerId} ); removeShutdownHook(); if (this.scheduler != null) { this.scheduler.stop(); this.scheduler = null; started.set(false); stopped.set(true); stoppedLatch.countDown();
try { if (!closed.get() && !transportFailed.get()) { doStop(false); if (!closed.get()) { closing.set(true); if (scheduler != null) { try { scheduler.stop(); } catch (Exception e) { JMSException ex = JMSExceptionSupport.create(e); removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId); try { syncSendPacket(removeCommand, closeTimeout); } catch (JMSException e) { if (e.getCause() instanceof RequestTimedOutIOException) { doAsyncSendPacket(new ShutdownInfo());
if (!started.get()) { return; LOG.info("ActiveMQ Message Broker (" + getBrokerName() + ", " + brokerId + ") is shutting down"); removeShutdownHook(); ServiceStopper stopper = new ServiceStopper(); if (services != null) { stopAllConnectors(stopper); stopped.set(true); stoppedLatch.countDown(); if (masterConnectorURI == null) { started.set(false); slaveStartSignal.countDown(); this.scheduler.stop(); this.scheduler = null;
@Override public void start() throws Exception { if (started.compareAndSet(false, true)) { if (memoryUsage != null) { memoryUsage.start(); } if (systemUsage.getStoreUsage() != null) { systemUsage.getStoreUsage().start(); } if (systemUsage.getTempUsage() != null) { systemUsage.getTempUsage().start(); } systemUsage.getMemoryUsage().addUsageListener(this); messages.start(); if (getExpireMessagesPeriod() > 0) { scheduler.executePeriodically(expireMessagesTask, getExpireMessagesPeriod()); } doPageIn(false); } }
if (clearInProgress.compareAndSet(false, true)) { for (final ActiveMQMessageConsumer consumer : consumers) { consumer.inProgressClearRequired(); transportInterruptionProcessingComplete.incrementAndGet(); try { connection.getScheduler().executeAfterDelay(new Runnable() { @Override public void run() { }}, 0l); } catch (JMSException e) { connection.onClientInternalException(e); connection.getScheduler().executeAfterDelay(new Runnable() { @Override public void run() {
@Override public void stop() throws Exception { if (started.compareAndSet(true, false)) { if (taskRunner != null) { taskRunner.shutdown(); scheduler.cancel(expireMessagesTask); systemUsage.getMemoryUsage().removeUsageListener(this); if (memoryUsage != null) { memoryUsage.stop(); if (systemUsage.getStoreUsage() != null) { systemUsage.getStoreUsage().stop();
@Override public void stop() throws Exception { if (started.compareAndSet(true, false)) { if (taskRunner != null) { taskRunner.shutdown(); } this.subscriptionRecoveryPolicy.stop(); if (memoryUsage != null) { memoryUsage.stop(); } if (this.topicStore != null) { this.topicStore.stop(); } scheduler.cancel(expireMessagesTask); } }
connection.rollbackDuplicate(ActiveMQSession.this, md.getMessage()); LOG.debug("No redelivery of {} on rollback of {} due to failover of {}", md, ack.getTransactionId(), connection.getTransport()); return; if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { LOG.debug("No local redelivery of {} on rollback of {} because consumer is no longer active on {}", md, ack.getTransactionId(), connection.getTransport()); return; connection.getScheduler().executeAfterDelay(new Runnable() {
public void stop() { if (!brokerService.isUseJmx()) { return; } scheduler.cancel(purgeInactiveDestinationViewTask); for (NetworkDestinationContainer networkDestinationContainer : inboundDestinationViewMap.values()) { try { brokerService.getManagementContext().unregisterMBean(networkDestinationContainer.objectName); } catch (Exception e) { LOG.error("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } } for (NetworkDestinationContainer networkDestinationContainer : outboundDestinationViewMap.values()) { try { brokerService.getManagementContext().unregisterMBean(networkDestinationContainer.objectName); } catch (Exception e) { LOG.debug("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } } inboundDestinationViewMap.clear(); outboundDestinationViewMap.clear(); }
/** * Schedules a periodic task based on schedulePeriodForDiskLimitCheck to * update store and temporary store limits if the amount of available space * plus current store size is less than the existin configured limit */ protected void scheduleDiskUsageLimitsCheck() throws IOException { if (schedulePeriodForDiskUsageCheck > 0 && (getPersistenceAdapter() != null || getTmpDataDirectory() != null)) { Runnable diskLimitCheckTask = new Runnable() { @Override public void run() { try { checkStoreUsageLimits(); } catch (Throwable e) { LOG.error("Failed to check persistent disk usage limits", e); } try { checkTmpStoreUsageLimits(); } catch (Throwable e) { LOG.error("Failed to check temporary store usage limits", e); } } }; scheduler.executePeriodically(diskLimitCheckTask, schedulePeriodForDiskUsageCheck); } }
@Override public void start() throws Exception { started = true; queueRegion.start(); topicRegion.start(); tempQueueRegion.start(); tempTopicRegion.start(); int period = this.brokerService.getSchedulePeriodForDestinationPurge(); if (period > 0) { this.scheduler.executePeriodically(purgeInactiveDestinationsTask, period); } }
scheduler = new Scheduler(PListStoreImpl.class.getSimpleName()); scheduler.start(); scheduler.executePeriodically(this, cleanupInterval);
public void stop() throws Exception { scheduler.cancel(gcTask); }
@Override protected synchronized void doStop(ServiceStopper stopper) throws Exception { if (scheduler != null) { if (PListStoreImpl.class.getSimpleName().equals(scheduler.getName())) { scheduler.stop(); scheduler = null; } } for (PListImpl pl : this.persistentLists.values()) { pl.unload(null); } if (this.pageFile != null) { this.pageFile.unload(); } if (this.journal != null) { journal.close(); } if (this.lockFile != null) { this.lockFile.unlock(); } this.lockFile = null; this.initialized = false; LOG.info(this + " stopped"); }