From 0e8386879eec4569e8178b85006dd1e47a77806b Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Wed, 7 Nov 2012 16:41:20 +0000 Subject: QPID-4426 Add exception callback to sessionreceiver callback server. This patch fixes the server and the csharp.map.callback.receiver.cs client example. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1406713 13f79535-47bb-0310-9956-ffa450edef68 --- .../csharp.map.callback.receiver.cs | 14 +++++++++ .../dotnet/src/sessionreceiver/sessionreceiver.cs | 34 +++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) (limited to 'qpid/cpp/bindings') diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs index b1ba949e07..72ddd44120 100644 --- a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs +++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs @@ -152,6 +152,20 @@ namespace Org.Apache.Qpid.Messaging.Examples } + /// + /// SessionReceiver implements the ISessionReceiver interface. + /// It is the exception function that receives all exception messages + /// It may be called any time server is running. + /// It is always called on server's private thread. + /// After this is called then the sessionReceiver and private thread are closed. + /// + /// The exception. + public void SessionException(Exception exception) + { + Console.WriteLine("{0} Exception caught.", exception.ToString()); + } + + /// /// Usage /// diff --git a/qpid/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs b/qpid/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs index 680732068f..a15a8d60fe 100644 --- a/qpid/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs +++ b/qpid/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs @@ -37,6 +37,7 @@ namespace Org.Apache.Qpid.Messaging.SessionReceiver public interface ISessionReceiver { void SessionReceiver(Receiver receiver, Message message); + void SessionException(Exception exception); } @@ -67,25 +68,32 @@ namespace Org.Apache.Qpid.Messaging.SessionReceiver { Receiver rcvr; Message msg; - - keepRunning = true; - while (keepRunning) + try { - rcvr = session.NextReceiver(DurationConstants.SECOND); - - if (null != rcvr) + keepRunning = true; + while (keepRunning) { - if (keepRunning) + rcvr = session.NextReceiver(DurationConstants.SECOND); + + if (null != rcvr) { - msg = rcvr.Fetch(DurationConstants.SECOND); - this.callback.SessionReceiver(rcvr, msg); + if (keepRunning) + { + msg = rcvr.Fetch(DurationConstants.SECOND); + this.callback.SessionReceiver(rcvr, msg); + } } + //else + // receive timed out + // EventEngine exits the nextReceiver() function periodically + // in order to test the keepRunning flag } - //else - // receive timed out - // EventEngine exits the nextReceiver() function periodically - // in order to test the keepRunning flag } + catch (Exception e) + { + this.callback.SessionException(e); + } + // Private thread is now exiting. } -- cgit v1.2.1