You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2012/11/14 16:13:37 UTC
svn commit: r1409220 - in /openejb/trunk/openejb:
container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
Author: andygumbrecht
Date: Wed Nov 14 15:13:36 2012
New Revision: 1409220
URL: http://svn.apache.org/viewvc?rev=1409220&view=rev
Log:
Ensure the broker starts and is 'always' checkpointed in our thread - Seems that setStartAsync(false) is also now required on ActiveMQ 5.8.
Add the error to the log in EjbRequestHandler.java.
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java?rev=1409220&r1=1409219&r2=1409220&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java Wed Nov 14 15:13:36 2012
@@ -50,6 +50,8 @@ public class ActiveMQ5Factory implements
@Override
public synchronized BrokerService createBroker(final URI brokerURI) throws Exception {
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "service").info("ActiveMQ5Factory creating broker: " + Thread.currentThread().getName());
+
BrokerService broker = brokers.get(brokerURI);
if (null == broker || !broker.isStarted()) {
@@ -106,76 +108,82 @@ public class ActiveMQ5Factory implements
disableScheduler(broker);
//Notify when an error occurs on shutdown.
- broker.setUseLoggingForShutdownErrors(org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources").isErrorEnabled());
+ broker.setUseLoggingForShutdownErrors(org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).isErrorEnabled());
}
//We must close the broker
broker.setUseShutdownHook(false);
broker.setSystemExitOnShutdown(false);
- if (!broker.isStarted()) {
+ broker.setStartAsync(false);
- final BrokerService bs = broker;
+ final BrokerService bs = broker;
- final Thread start = new Thread("ActiveMQFactory start and checkpoint") {
+ final Thread start = new Thread("ActiveMQFactory start and checkpoint") {
- @Override
- public void run() {
+ @Override
+ public void run() {
- try {
- //Start before returning - this is known to be safe.
+ try {
+ //Start before returning - this is known to be safe.
+ if (!bs.isStarted()) {
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").info("Starting ActiveMQ BrokerService");
bs.start();
- bs.waitUntilStarted();
-
- //Force a checkpoint to initialize pools
- bs.getPersistenceAdapter().checkpoint(true);
- started.set(true);
- } catch (Throwable t) {
- throwable = t;
}
- }
- };
- /*
- * An application may require immediate access to JMS. So we need to block here until the service
- * has started. How long ActiveMQ requires to actually create a broker is unpredictable.
- *
- * A broker in OpenEJB is usually a wrapper for an embedded ActiveMQ server service. The broker configuration
- * allows the definition of a remote ActiveMQ server, in which case startup is not an issue as the broker is
- * basically a client.
- *
- * If the broker is local and the message store contains millions of messages then the startup time is obviously going to
- * be longer as these need to be indexed by ActiveMQ.
- *
- * A balanced timeout will always be use case dependent.
- */
-
- int timeout = 60000;
-
- try {
- timeout = Integer.parseInt(properties.getProperty("startuptimeout", "60000"));
- org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources").info("Using ActiveMQ startup timeout of " + timeout + "ms");
- } catch (Throwable e) {
- //Ignore
- }
+ bs.waitUntilStarted();
- start.setDaemon(true);
- start.start();
+ //Force a checkpoint to initialize pools
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").info("Starting ActiveMQ checkpoint");
+ bs.getPersistenceAdapter().checkpoint(true);
+ started.set(true);
- try {
- start.join(timeout);
- } catch (InterruptedException e) {
- //Ignore
+ } catch (Throwable t) {
+ throwable = t;
+ }
}
+ };
- if (null != throwable) {
- org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources").error("ActiveMQ failed to start broker", throwable);
- } else if (started.get()) {
- org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources").info("ActiveMQ broker started");
- } else {
- org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources").warning("ActiveMQ failed to start broker within " + timeout + " seconds - It may be unusable");
- }
+ /*
+ * An application may require immediate access to JMS. So we need to block here until the service
+ * has started. How long ActiveMQ requires to actually create a broker is unpredictable.
+ *
+ * A broker in OpenEJB is usually a wrapper for an embedded ActiveMQ server service. The broker configuration
+ * allows the definition of a remote ActiveMQ server, in which case startup is not an issue as the broker is
+ * basically a client.
+ *
+ * If the broker is local and the message store contains millions of messages then the startup time is obviously going to
+ * be longer as these need to be indexed by ActiveMQ.
+ *
+ * A balanced timeout will always be use case dependent.
+ */
+
+ int timeout = 30000;
+
+ try {
+ timeout = Integer.parseInt(properties.getProperty("startuptimeout", "30000"));
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").info("Using ActiveMQ startup timeout of " + timeout + "ms");
+ } catch (Throwable e) {
+ //Ignore
+ }
+
+ start.setDaemon(true);
+ start.start();
+
+ try {
+ start.join(timeout);
+ } catch (InterruptedException e) {
+ //Ignore
}
+
+ if (null != throwable) {
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").error("ActiveMQ failed to start broker", throwable);
+ } else if (started.get()) {
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").info("ActiveMQ broker started");
+ } else {
+ org.apache.openejb.util.Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service").warning("ActiveMQ failed to start broker within " + timeout + " seconds - It may be unusable");
+ }
+
}
return broker;
Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java?rev=1409220&r1=1409219&r2=1409220&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java (original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java Wed Nov 14 15:13:36 2012
@@ -497,7 +497,7 @@ class EjbRequestHandler {
//This is fatal for the client, but not the server.
if (logger.isWarningEnabled()) {
- logger.warning(message + " - Debug for stacktrace");
+ logger.warning(message + " - Debug for stacktrace: " + error);
} else if (logger.isDebugEnabled()) {
logger.debug(message, error);
}
@@ -512,7 +512,7 @@ class EjbRequestHandler {
if (logger.isDebugEnabled()) {
logger.debug("Failed to write EjbResponse", t);
} else if (logger.isWarningEnabled()) {
- logger.warning("Failed to write EjbResponse - Debug for stacktrace");
+ logger.warning("Failed to write EjbResponse - Debug for stacktrace: " + t);
}
}
}