https://issues.apache.org/jira/browse/AMQ-3696 - use startAsync property instead of separate method

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1363003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2012-07-18 16:19:31 +00:00
parent ed58e9a05d
commit eebe1358d2
4 changed files with 16 additions and 17 deletions

View File

@ -222,8 +222,8 @@ public class BrokerService implements Service {
private DestinationFilter virtualConsumerDestinationFilter;
private final Object persistenceAdapterLock = new Object();
private boolean persistenceAdapterStarted = false;
private Throwable startException = null;
private boolean startAsync = false;
static {
String localHostName = "localhost";
@ -496,19 +496,11 @@ public class BrokerService implements Service {
@PostConstruct
public void autoStart() throws Exception {
if(shouldAutostart()) {
startAsync();
start();
}
}
public void start() throws Exception {
doStart(false);
}
public void startAsync() throws Exception {
doStart(true);
}
public void doStart(boolean async) throws Exception {
if (stopped.get() || !started.compareAndSet(false, true)) {
// lets just ignore redundant start() calls
// as its way too easy to not be completely sure if start() has been
@ -529,9 +521,8 @@ public class BrokerService implements Service {
startManagementContext();
}
startPersistenceAdapter(async);
startBroker(async);
startedLatch.countDown();
startPersistenceAdapter(startAsync);
startBroker(startAsync);
} catch (Exception e) {
LOG.error("Failed to start ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId + "). Reason: " + e, e);
try {
@ -599,7 +590,6 @@ public class BrokerService implements Service {
}
private void doStartBroker() throws Exception {
if (startException != null) {
return;
}
@ -644,6 +634,7 @@ public class BrokerService implements Service {
LOG.info("ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId + ") started");
getBroker().brokerServiceStarted();
checkSystemUsageLimits();
startedLatch.countDown();
}
/**
@ -2790,4 +2781,12 @@ public class BrokerService implements Service {
public Throwable getStartException() {
return startException;
}
public boolean isStartAsync() {
return startAsync;
}
public void setStartAsync(boolean startAsync) {
this.startAsync = startAsync;
}
}

View File

@ -57,7 +57,7 @@ public class XBeanBrokerService extends BrokerService {
public void afterPropertiesSet() throws Exception {
ensureSystemUsageHasStore();
if (shouldAutostart()) {
startAsync();
start();
}
}

View File

@ -22,7 +22,7 @@
<!-- Allows us to use system properties as variables in this configuration file -->
<ext:property-placeholder />
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="${name}" dataDirectory="${karaf.data}/activemq/${name}" useShutdownHook="false">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="${name}" dataDirectory="${karaf.data}/activemq/${name}" useShutdownHook="false" startAsync="true">
<!--
For better performances use VM cursor and small memory limit.

View File

@ -27,7 +27,7 @@
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="${name}" dataDirectory="${karaf.data}/activemq/${name}" useShutdownHook="false">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="${name}" dataDirectory="${karaf.data}/activemq/${name}" useShutdownHook="false" startAsync="true">
<!--
For better performances use VM cursor and small memory limit.