You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/09 01:37:58 UTC
svn commit: r1371016 - in
/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src: main/csharp/Commands/
main/csharp/Protocol/ main/csharp/Transport/ main/csharp/Transport/Tcp/
test/csharp/
Author: tabish
Date: Wed Aug 8 23:37:58 2012
New Revision: 1371016
URL: http://svn.apache.org/viewvc?rev=1371016&view=rev
Log:
initial fix for: https://issues.apache.org/jira/browse/AMQNET-384
refactor the InactivityMonitor setting code for inactivity duration values.
Modified:
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/InactivityMonitor.cs
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/SpecialCharactersTest.cs
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs?rev=1371016&r1=1371015&r2=1371016&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs Wed Aug 8 23:37:58 2012
@@ -27,9 +27,6 @@ namespace Apache.NMS.Stomp.Commands
string password;
string userName;
- long maxInactivityDuration = 30000;
- long maxInactivityDurationInitialDelay = 0;
-
/// <summery>
/// Get the unique identifier that this object and its own
/// Marshaler share.
@@ -48,10 +45,6 @@ namespace Apache.NMS.Stomp.Commands
return GetType().Name + "[" +
"ConnectionId=" + ConnectionId + ", " +
"Host=" + Host + ", " +
- "MaxInactivityDuration=" + MaxInactivityDuration + ", " +
- "ReadCheckInterval=" + ReadCheckInterval + ", " +
- "WriteCheckInterval=" + WriteCheckInterval + ", " +
- "MaxInactivityDurationInitialDelay=" + MaxInactivityDurationInitialDelay + ", " +
"ClientId=" + ClientId + ", " +
"Password=" + Password + ", " +
"UserName=" + UserName +
@@ -88,28 +81,6 @@ namespace Apache.NMS.Stomp.Commands
set { this.userName = value; }
}
- public long MaxInactivityDuration
- {
- get { return this.maxInactivityDuration; }
- set { this.maxInactivityDuration = value; }
- }
-
- public long MaxInactivityDurationInitialDelay
- {
- get { return this.maxInactivityDurationInitialDelay; }
- set { this.maxInactivityDurationInitialDelay = value; }
- }
-
- public long ReadCheckInterval
- {
- get { return this.MaxInactivityDuration; }
- }
-
- public long WriteCheckInterval
- {
- get { return maxInactivityDuration > 3 ? maxInactivityDuration / 3 : maxInactivityDuration; }
- }
-
/// <summery>
/// Return an answer of true to the isConnectionInfo() query.
/// </summery>
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=1371016&r1=1371015&r2=1371016&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs Wed Aug 8 23:37:58 2012
@@ -34,6 +34,8 @@ namespace Apache.NMS.Stomp.Protocol
private WireFormatInfo remoteWireFormatInfo;
private int connectedResponseId = -1;
private bool encodeHeaders = false;
+ private int maxInactivityDuration = 30000;
+ private int maxInactivityDurationInitialDelay = 0;
public StompWireFormat()
{
@@ -62,6 +64,28 @@ namespace Apache.NMS.Stomp.Protocol
set { this.mapMarshaler = value; }
}
+ public int MaxInactivityDuration
+ {
+ get { return this.maxInactivityDuration; }
+ set { this.maxInactivityDuration = value; }
+ }
+
+ public int MaxInactivityDurationInitialDelay
+ {
+ get { return this.maxInactivityDurationInitialDelay; }
+ set { this.maxInactivityDurationInitialDelay = value; }
+ }
+
+ public long ReadCheckInterval
+ {
+ get { return this.MaxInactivityDuration; }
+ }
+
+ public long WriteCheckInterval
+ {
+ get { return maxInactivityDuration > 3 ? maxInactivityDuration / 3 : maxInactivityDuration; }
+ }
+
public void Marshal(Object o, BinaryWriter dataOut)
{
Tracer.Debug("StompWireFormat - Marshaling: " + o);
@@ -468,9 +492,9 @@ namespace Apache.NMS.Stomp.Protocol
frame.SetProperty("host", command.Host);
frame.SetProperty("accept-version", "1.0,1.1");
- if(command.MaxInactivityDuration != 0)
+ if(MaxInactivityDuration != 0)
{
- frame.SetProperty("heart-beat", command.WriteCheckInterval + "," + command.ReadCheckInterval);
+ frame.SetProperty("heart-beat", WriteCheckInterval + "," + ReadCheckInterval);
}
if(Tracer.IsDebugEnabled)
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/InactivityMonitor.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/InactivityMonitor.cs?rev=1371016&r1=1371015&r2=1371016&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/InactivityMonitor.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/InactivityMonitor.cs Wed Aug 8 23:37:58 2012
@@ -20,6 +20,7 @@ using System.Threading;
using Apache.NMS.Stomp.Commands;
using Apache.NMS.Stomp.Threads;
using Apache.NMS.Stomp.Util;
+using Apache.NMS.Stomp.Protocol;
using Apache.NMS.Util;
namespace Apache.NMS.Stomp.Transport
@@ -76,17 +77,19 @@ namespace Apache.NMS.Stomp.Transport
}
// Local and remote Wire Format Information
- private ConnectionInfo localWireFormatInfo;
+ private StompWireFormat localWireFormatInfo;
private WireFormatInfo remoteWireFormatInfo;
/// <summary>
/// Constructor or the Inactivity Monitor
/// </summary>
/// <param name="next"></param>
- public InactivityMonitor(ITransport next)
+ /// <param name="wireFormat"></param>
+ public InactivityMonitor(ITransport next, StompWireFormat wireFormat)
: base(next)
{
this.instanceId = ++id;
+ this.localWireFormatInfo = wireFormat;
Tracer.Debug("Creating Inactivity Monitor: " + instanceId);
}
@@ -260,7 +263,6 @@ namespace Apache.NMS.Stomp.Transport
{
lock(monitor)
{
- localWireFormatInfo = command as ConnectionInfo;
StartMonitorThreads();
}
}
@@ -313,7 +315,7 @@ namespace Apache.NMS.Stomp.Transport
{
readCheckTime =
Math.Max(
- localWireFormatInfo.ReadCheckInterval,
+ localWireFormatInfo.MaxInactivityDuration,
remoteWireFormatInfo.WriteCheckInterval);
this.asyncErrorTask = new AsyncSignalReadErrorkTask(this, next.RemoteAddress);
@@ -324,7 +326,7 @@ namespace Apache.NMS.Stomp.Transport
if(remoteWireFormatInfo.Version > 1.0)
{
writeCheckTime =
- Math.Max(localWireFormatInfo.WriteCheckInterval,
+ Math.Max(localWireFormatInfo.MaxInactivityDuration,
remoteWireFormatInfo.ReadCheckInterval);
}
else
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs?rev=1371016&r1=1371015&r2=1371016&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs Wed Aug 8 23:37:58 2012
@@ -115,7 +115,7 @@ namespace Apache.NMS.Stomp.Transport.Tcp
socket.SendTimeout = SendTimeout;
#endif
- IWireFormat wireformat = new StompWireFormat();
+ StompWireFormat wireformat = new StompWireFormat();
// Set wireformat. properties on the wireformat owned by the tcpTransport
URISupport.SetProperties(wireformat, map, "wireFormat.");
ITransport transport = DoCreateTransport(location, socket, wireformat);
@@ -129,7 +129,7 @@ namespace Apache.NMS.Stomp.Transport.Tcp
if(UseInactivityMonitor)
{
- transport = new InactivityMonitor(transport);
+ transport = new InactivityMonitor(transport, wireformat);
}
if(setTransport != null)
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/SpecialCharactersTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/SpecialCharactersTest.cs?rev=1371016&r1=1371015&r2=1371016&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/SpecialCharactersTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/SpecialCharactersTest.cs Wed Aug 8 23:37:58 2012
@@ -27,15 +27,12 @@ namespace Apache.NMS.Stomp.Test
public class SpecialCharactersTest : NMSTestSupport
{
private Connection connection;
- private int counter;
private ISession session;
[SetUp]
public override void SetUp()
{
this.connection = (Connection) CreateConnection();
-
- this.counter = 0;
}
[TearDown]