AMQ-4049: Polished the AMQ start and stop logging.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1384714 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-09-14 10:34:54 +00:00
parent dd8899e173
commit c9cc85bde1
1 changed files with 19 additions and 15 deletions

View File

@ -578,13 +578,13 @@ public class BrokerService implements Service {
startBroker(startAsync); startBroker(startAsync);
brokerRegistry.bind(getBrokerName(), BrokerService.this); brokerRegistry.bind(getBrokerName(), BrokerService.this);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Failed to start ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId + "). Reason: " + e, e); LOG.error("Failed to start Apache ActiveMQ (" + getBrokerName() + ", " + brokerId + "). Reason: " + e, e);
try { try {
if (!stopped.get()) { if (!stopped.get()) {
stop(); stop();
} }
} catch (Exception ex) { } catch (Exception ex) {
LOG.warn("Failed to stop broker after failure in start ", ex); LOG.warn("Failed to stop broker after failure in start. This exception will be ignored.", ex);
} }
throw e; throw e;
} finally { } finally {
@ -650,7 +650,17 @@ public class BrokerService implements Service {
slave = false; slave = false;
startDestinations(); startDestinations();
addShutdownHook(); addShutdownHook();
getBroker().start();
broker = getBroker();
brokerId = broker.getBrokerId();
// need to log this after creating the broker so we have its id and name
if (LOG.isInfoEnabled()) {
LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
+ getBrokerName() + ", " + brokerId + ") is starting");
}
broker.start();
if (isUseJmx()) { if (isUseJmx()) {
if (getManagementContext().isCreateConnector() && !getManagementContext().isConnectorStarted()) { if (getManagementContext().isCreateConnector() && !getManagementContext().isConnectorStarted()) {
// try to restart management context // try to restart management context
@ -678,16 +688,14 @@ public class BrokerService implements Service {
registerFTConnectorMBean(masterConnector); registerFTConnectorMBean(masterConnector);
} }
} }
if (brokerId == null) {
brokerId = broker.getBrokerId();
}
if (ioExceptionHandler == null) { if (ioExceptionHandler == null) {
setIoExceptionHandler(new DefaultIOExceptionHandler()); setIoExceptionHandler(new DefaultIOExceptionHandler());
} }
if (LOG.isInfoEnabled()) { if (LOG.isInfoEnabled()) {
LOG.info("ActiveMQ " + getBrokerVersion() + " JMS Message Broker (" LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
+ getBrokerName() + ", " + brokerId + ") started"); + getBrokerName() + ", " + brokerId + ") started");
LOG.info("For help or more information please see: http://activemq.apache.org");
} }
getBroker().brokerServiceStarted(); getBroker().brokerServiceStarted();
@ -719,7 +727,7 @@ public class BrokerService implements Service {
} }
if (LOG.isInfoEnabled()) { if (LOG.isInfoEnabled()) {
LOG.info("ActiveMQ " + getBrokerVersion() + " JMS Message Broker (" LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
+ getBrokerName() + ", " + brokerId + ") is shutting down"); + getBrokerName() + ", " + brokerId + ") is shutting down");
} }
@ -795,9 +803,10 @@ public class BrokerService implements Service {
if (LOG.isInfoEnabled()) { if (LOG.isInfoEnabled()) {
if (startDate != null) { if (startDate != null) {
LOG.info("Uptime {}", getUptime()); LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
+ getBrokerName() + ", " + brokerId + ") uptime " + getUptime());
} }
LOG.info("ActiveMQ " + getBrokerVersion() + " JMS Message Broker (" LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
+ getBrokerName() + ", " + brokerId + ") is shutdown"); + getBrokerName() + ", " + brokerId + ") is shutdown");
} }
@ -929,11 +938,6 @@ public class BrokerService implements Service {
*/ */
public Broker getBroker() throws Exception { public Broker getBroker() throws Exception {
if (broker == null) { if (broker == null) {
if (LOG.isInfoEnabled()) {
LOG.info("ActiveMQ " + getBrokerVersion() + " JMS Message Broker ("
+ getBrokerName() + ") is starting");
LOG.info("For help or more information please see: http://activemq.apache.org/");
}
broker = createBroker(); broker = createBroker();
} }
return broker; return broker;