Author: jgomes
Date: Tue Apr 8 10:42:27 2008
New Revision: 646014
URL: http://svn.apache.org/viewvc?rev=646014&view=rev
Log:
Add more robust try/catch handling.
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
Tue Apr 8 10:42:27 2008
@@ -5,7 +5,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.832
+// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs
Tue Apr 8 10:42:27 2008
@@ -138,11 +138,14 @@
answer.ConnectionId = connectionId;
answer.UserName = userName;
answer.Password = password;
- answer.ClientId = clientId;
- if (clientId == null)
+ if(clientId == null)
{
answer.ClientId = CreateNewGuid();
}
+ else
+ {
+ answer.ClientId = clientId;
+ }
return answer;
}
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
Tue Apr 8 10:42:27 2008
@@ -152,21 +152,25 @@
{
return;
}
- }
- // wake up any pending dequeue() call on the dispatcher
- dispatcher.Close();
- session.DisposeOf(info.ConsumerId);
- session = null;
+ try
+ {
+ // wake up any pending dequeue() call
on the dispatcher
+ dispatcher.Close();
+ session.DisposeOf(info.ConsumerId);
- lock(this)
- {
- if(ackSession != null)
+ if(ackSession != null)
+ {
+ ackSession.Close();
+ }
+ }
+ catch(Exception ex)
{
- ackSession.Close();
- ackSession = null;
+ Tracer.ErrorFormat("Error during
consumer close: {0}", ex);
}
+ session = null;
+ ackSession = null;
closed = true;
}
}
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
Tue Apr 8 10:42:27 2008
@@ -87,13 +87,17 @@
{
return;
}
- }
- session.DisposeOf(info.ProducerId);
- session = null;
+ try
+ {
+ session.DisposeOf(info.ProducerId);
+ }
+ catch(Exception ex)
+ {
+ Tracer.ErrorFormat("Error during
producer close: {0}", ex);
+ }
- lock(this)
- {
+ session = null;
closed = true;
}
}
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
Tue Apr 8 10:42:27 2008
@@ -44,6 +44,7 @@
private readonly TransactionContext transactionContext;
internal bool startedAsyncDelivery = false;
private bool disposed = false;
+ private bool closed = false;
public Session(Connection connection, SessionInfo info,
AcknowledgementMode acknowledgementMode)
{
@@ -176,6 +177,41 @@
disposed = true;
}
+ public void Close()
+ {
+ lock(this)
+ {
+ if(closed)
+ {
+ return;
+ }
+
+ try
+ {
+ connection.RemoveSession(this);
+ StopAsyncDelivery();
+ foreach(MessageConsumer consumer in
GetConsumers())
+ {
+ consumer.Close();
+ }
+ consumers.Clear();
+
+ foreach(MessageProducer producer in
GetProducers())
+ {
+ producer.Close();
+ }
+ producers.Clear();
+ }
+ catch(Exception ex)
+ {
+ Tracer.ErrorFormat("Error during
session close: {0}", ex);
+ }
+
+ connection = null;
+ closed = true;
+ }
+ }
+
public IMessageProducer CreateProducer()
{
return CreateProducer(null);
@@ -386,24 +422,6 @@
public bool Transacted
{
get { return acknowledgementMode ==
AcknowledgementMode.Transactional; }
- }
-
- public void Close()
- {
- connection.RemoveSession(this);
- StopAsyncDelivery();
- foreach(MessageConsumer consumer in GetConsumers())
- {
- consumer.Close();
- }
- consumers.Clear();
-
- foreach(MessageProducer producer in GetProducers())
- {
- producer.Close();
- }
- producers.Clear();
- connection = null;
}
#endregion
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs?rev=646014&r1=646013&r2=646014&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs
Tue Apr 8 10:42:27 2008
@@ -5,7 +5,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.832
+// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.