activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1514023 - in /activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp: ProtocolConverter.java StompTransportFilter.java
Date Wed, 14 Aug 2013 20:19:07 GMT
Author: tabish
Date: Wed Aug 14 20:19:06 2013
New Revision: 1514023

URL: http://svn.apache.org/r1514023
Log:
fix: https://issues.apache.org/jira/browse/AMQ-4674

add transport options "?transport.hbGracePeriodMultiplier" which is used to add a user defined
grace period to the read check interval indicated by the connecting STOMP client. 

Modified:
    activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
    activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java

Modified: activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java?rev=1514023&r1=1514022&r2=1514023&view=diff
==============================================================================
--- activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
(original)
+++ activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
Wed Aug 14 20:19:06 2013
@@ -34,33 +34,7 @@ import org.apache.activemq.ActiveMQPrefe
 import org.apache.activemq.advisory.AdvisorySupport;
 import org.apache.activemq.broker.BrokerContext;
 import org.apache.activemq.broker.BrokerContextAware;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQTempQueue;
-import org.apache.activemq.command.ActiveMQTempTopic;
-import org.apache.activemq.command.Command;
-import org.apache.activemq.command.CommandTypes;
-import org.apache.activemq.command.ConnectionError;
-import org.apache.activemq.command.ConnectionId;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerControl;
-import org.apache.activemq.command.ConsumerId;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.DestinationInfo;
-import org.apache.activemq.command.ExceptionResponse;
-import org.apache.activemq.command.LocalTransactionId;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.MessageDispatch;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.RemoveSubscriptionInfo;
-import org.apache.activemq.command.Response;
-import org.apache.activemq.command.SessionId;
-import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.command.ShutdownInfo;
-import org.apache.activemq.command.TransactionId;
-import org.apache.activemq.command.TransactionInfo;
+import org.apache.activemq.command.*;
 import org.apache.activemq.util.ByteArrayOutputStream;
 import org.apache.activemq.util.FactoryFinder;
 import org.apache.activemq.util.IOExceptionSupport;
@@ -124,6 +98,7 @@ public class ProtocolConverter {
     private String version = "1.0";
     private long hbReadInterval;
     private long hbWriteInterval;
+    private float hbGracePeriodMultiplier = 1.0f;
     private String defaultHeartBeat = Stomp.DEFAULT_HEART_BEAT;
 
     private static class AckEntry {
@@ -928,6 +903,20 @@ public class ProtocolConverter {
         this.defaultHeartBeat = defaultHeartBeat;
     }
 
+    /**
+     * @return the hbGracePeriodMultiplier
+     */
+    public float getHbGracePeriodMultiplier() {
+        return hbGracePeriodMultiplier;
+    }
+
+    /**
+     * @param hbGracePeriodMultiplier the hbGracePeriodMultiplier to set
+     */
+    public void setHbGracePeriodMultiplier(float hbGracePeriodMultiplier) {
+        this.hbGracePeriodMultiplier = hbGracePeriodMultiplier;
+    }
+
     protected void configureInactivityMonitor(String heartBeatConfig) throws ProtocolException
{
 
         String[] keepAliveOpts = heartBeatConfig.split(Stomp.COMMA);
@@ -937,7 +926,7 @@ public class ProtocolConverter {
         } else {
 
             try {
-                hbReadInterval = Long.parseLong(keepAliveOpts[0]);
+                hbReadInterval = (long) (Long.parseLong(keepAliveOpts[0]) * hbGracePeriodMultiplier);
                 hbWriteInterval = Long.parseLong(keepAliveOpts[1]);
             } catch(NumberFormatException e) {
                 throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig,
true);
@@ -945,7 +934,7 @@ public class ProtocolConverter {
 
             try {
                 StompInactivityMonitor monitor = this.stompTransport.getInactivityMonitor();
-                monitor.setReadCheckTime(hbReadInterval);
+                monitor.setReadCheckTime((long) (hbReadInterval * hbGracePeriodMultiplier));
                 monitor.setInitialDelayTime(Math.min(hbReadInterval, hbWriteInterval));
                 monitor.setWriteCheckTime(hbWriteInterval);
                 monitor.startMonitoring();

Modified: activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java?rev=1514023&r1=1514022&r2=1514023&view=diff
==============================================================================
--- activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java
(original)
+++ activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java
Wed Aug 14 20:19:06 2013
@@ -55,6 +55,7 @@ public class StompTransportFilter extend
         }
     }
 
+    @Override
     public void oneway(Object o) throws IOException {
         try {
             final Command command = (Command) o;
@@ -64,6 +65,7 @@ public class StompTransportFilter extend
         }
     }
 
+    @Override
     public void onCommand(Object command) {
         try {
             if (trace) {
@@ -78,6 +80,7 @@ public class StompTransportFilter extend
         }
     }
 
+    @Override
     public void sendToActiveMQ(Command command) {
         TransportListener l = transportListener;
         if (l != null) {
@@ -85,6 +88,7 @@ public class StompTransportFilter extend
         }
     }
 
+    @Override
     public void sendToStomp(StompFrame command) throws IOException {
         if (trace) {
             TRACE.trace("Sending: \n" + command);
@@ -125,4 +129,28 @@ public class StompTransportFilter extend
         protocolConverter.setDefaultHeartBeat(defaultHeartBeat);
     }
 
+    /**
+     * Returns the currently configured Read check grace period multiplier.
+     *
+     * @return the hbGracePeriodMultiplier
+     */
+    public float getHbGracePeriodMultiplier() {
+        return protocolConverter != null ? protocolConverter.getHbGracePeriodMultiplier()
: null;
+    }
+
+    /**
+     * Sets the read check grace period multiplier.  New CONNECT frames that indicate a heart
beat
+     * value with a read check interval will have that value multiplied by this value to
add a
+     * grace period before the connection is considered invalid.  By default this value is
set to
+     * zero and no grace period is given.  When set the value must be larger than 1.0 or
it will
+     * be ignored.
+     *
+     * @param hbGracePeriodMultiplier the hbGracePeriodMultiplier to set
+     */
+    public void setHbGracePeriodMultiplier(float hbGracePeriodMultiplier) {
+        if (hbGracePeriodMultiplier > 1.0f) {
+            protocolConverter.setHbGracePeriodMultiplier(hbGracePeriodMultiplier);
+        }
+    }
+
 }



Mime
View raw message