From 9d53c53dc81aa17cef18c86131cd37c57b91392b Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 24 May 2007 10:28:32 +0000 Subject: [PATCH] improvement for AMQ-1253 so that the ConnectionFactory can be configured with the warning timeout (or have the warning disabled all together) git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@541259 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/ActiveMQConnection.java | 2 +- .../activemq/ActiveMQConnectionFactory.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java index 99d5bb64a3..d1218cf400 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java @@ -1514,7 +1514,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon } /** - * Enables the timemout from a session creation to when a warning is generated + * Enables the timemout from a connection creation to when a warning is generated * if the connection is not properly started via {@link #start()}. It is a very * common gotcha to forget to * start the connection diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java index 439ae21e31..40a5e056ce 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java @@ -92,6 +92,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne private boolean alwaysSyncSend; private boolean watchTopicAdvisories=true; private int producerWindowSize=DEFAULT_PRODUCER_WINDOW_SIZE; + private long warnAboutUnstartedConnectionTimeout = 500L; static protected final Executor DEFAULT_CONNECTION_EXECUTOR = new ScheduledThreadPoolExecutor(5, new ThreadFactory() { public Thread newThread(Runnable run) { @@ -267,6 +268,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne connection.setBlobTransferPolicy(getBlobTransferPolicy().copy()); connection.setWatchTopicAdvisories(watchTopicAdvisories); connection.setProducerWindowSize(producerWindowSize); + connection.setWarnAboutUnstartedConnectionTimeout(getWarnAboutUnstartedConnectionTimeout()); transport.start(); if( clientID !=null ) @@ -756,4 +758,21 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne synchronized public void setProducerWindowSize(int producerWindowSize) { this.producerWindowSize = producerWindowSize; } + + + public long getWarnAboutUnstartedConnectionTimeout() { + return warnAboutUnstartedConnectionTimeout; + } + + /** + * Enables the timemout from a connection creation to when a warning is generated + * if the connection is not properly started via {@link Connection#start()}. It is a very + * common gotcha to forget to + * start the connection + * so this option makes the default case to create a warning if the user forgets. + * To disable the warning just set the value to < 0 (say -1). + */ + public void setWarnAboutUnstartedConnectionTimeout(long warnAboutUnstartedConnectionTimeout) { + this.warnAboutUnstartedConnectionTimeout = warnAboutUnstartedConnectionTimeout; + } }