diff options
| author | Charles E. Rolke <chug@apache.org> | 2012-11-07 16:41:20 +0000 |
|---|---|---|
| committer | Charles E. Rolke <chug@apache.org> | 2012-11-07 16:41:20 +0000 |
| commit | 0e8386879eec4569e8178b85006dd1e47a77806b (patch) | |
| tree | 4427ad547be47f60eb1d66821c0a766875a0506e /qpid/cpp | |
| parent | cc7fe438f414323d659692f753ba197cf80489ba (diff) | |
| download | qpid-python-0e8386879eec4569e8178b85006dd1e47a77806b.tar.gz | |
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
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs | 14 | ||||
| -rw-r--r-- | qpid/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs | 34 |
2 files changed, 35 insertions, 13 deletions
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 @@ -153,6 +153,20 @@ namespace Org.Apache.Qpid.Messaging.Examples /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="exception">The exception.</param>
+ public void SessionException(Exception exception)
+ {
+ Console.WriteLine("{0} Exception caught.", exception.ToString());
+ }
+
+
+ /// <summary>
/// Usage
/// </summary>
/// <param name="url">Connection target</param>
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.
}
|
