From 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Thu, 28 Feb 2013 16:14:30 +0000 Subject: Update from trunk r1375509 through r1450773 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qpid/dotnet/configure-windows.ps1 | 41 +++++++++++++--------- .../csharp.map.callback.receiver.cs | 28 +++++++++++++-- .../org.apache.qpid.messaging.sessionreceiver.sln | 2 +- cpp/bindings/qpid/dotnet/src/Receiver.cpp | 31 ++++++++++++++-- .../dotnet/src/sessionreceiver/sessionreceiver.cs | 34 +++++++++++------- 5 files changed, 101 insertions(+), 35 deletions(-) (limited to 'cpp/bindings/qpid/dotnet') diff --git a/cpp/bindings/qpid/dotnet/configure-windows.ps1 b/cpp/bindings/qpid/dotnet/configure-windows.ps1 index 162ac272b4..60b2b539bd 100644 --- a/cpp/bindings/qpid/dotnet/configure-windows.ps1 +++ b/cpp/bindings/qpid/dotnet/configure-windows.ps1 @@ -24,8 +24,8 @@ # This script configures a qpid\cpp developer build environment under Windows # to enable working with cpp\bindings\qpid\dotnet binding source code. # -# * Supports multiple versions of Visual Studio (VS2008, VS2010) as CMake -# generator. +# * Supports multiple versions of Visual Studio (VS2008, VS2010, VS2012) +# as CMake generator. # # * Supports 32-bit and/or 64-bit development platforms. # @@ -148,10 +148,11 @@ $global:txtWH = 'Write-Host' ############################# # Visual Studio version selection dialog items and choice # -[array]$global:VsVersionCmakeChoiceList = "Visual Studio 2010", "Visual Studio 2008" +[array]$global:VsVersionCmakeChoiceList = "Visual Studio 2012", "Visual Studio 2010", "Visual Studio 2008" $global:vsVersion = '' $global:cmakeGenerator = '' $global:vsSubdir = '' +$global:cmakeCompiler = '' ############################# # Select-Folder @@ -352,18 +353,26 @@ ECHO Environment set for $slnName $studioVersion $vsPlatform $nBits-bit developm function Return-DropDown { if ($DropDown.SelectedItem -ne $null) { $global:vsVersion = $DropDown.SelectedItem.ToString() - if ($global:vsVersion -eq 'Visual Studio 2010') { - $global:cmakeGenerator = "Visual Studio 10" - $global:vsSubdir = "msvc10" + if ($global:vsVersion -eq 'Visual Studio 2012') { + $global:cmakeGenerator = "Visual Studio 11" + $global:vsSubdir = "msvc11" + $global:cmakeCompiler = "-vc110" } else { - if ($global:vsVersion -eq 'Visual Studio 2008') { - $global:cmakeGenerator = "Visual Studio 9 2008" - $global:vsSubdir = "msvc9" - } else { - Write-Host "Visual Studio must be 2008 or 2010" - exit - } - } + if ($global:vsVersion -eq 'Visual Studio 2010') { + $global:cmakeGenerator = "Visual Studio 10" + $global:vsSubdir = "msvc10" + $global:cmakeCompiler = "-vc100" + } else { + if ($global:vsVersion -eq 'Visual Studio 2008') { + $global:cmakeGenerator = "Visual Studio 9 2008" + $global:vsSubdir = "msvc9" + $global:cmakeCompiler = "-vc90" + } else { + Write-Host "Visual Studio must be 2008, 2010, or 2012" + exit + } + } + } $Form.Close() Write-Host "Selected generator: $global:cmakeGenerator" } @@ -496,7 +505,7 @@ if ($make32) { $env:BOOST_ROOT = "$boost32" cd "$build32" Write-Host "Running 32-bit CMake in $build32 ..." - CMake -G "$global:cmakeGenerator" "-DCMAKE_INSTALL_PREFIX=install_x86" $cppDir + CMake -G "$global:cmakeGenerator" "-DGEN_DOXYGEN=No" "-DCMAKE_INSTALL_PREFIX=install_x86" "-DBoost_COMPILER=$global:cmakeCompiler" $cppDir } else { Write-Host "Skipped 32-bit CMake." } @@ -508,7 +517,7 @@ if ($make64) { $env:BOOST_ROOT = "$boost64" cd "$build64" Write-Host "Running 64-bit CMake in $build64" - CMake -G "$global:cmakeGenerator Win64" "-DCMAKE_INSTALL_PREFIX=install_x64" $cppDir + CMake -G "$global:cmakeGenerator Win64" "-DGEN_DOXYGEN=No" "-DCMAKE_INSTALL_PREFIX=install_x64" "-DBoost_COMPILER=$global:cmakeCompiler" $cppDir } else { Write-Host "Skipped 64-bit CMake." } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs index b1ba949e07..3bc22b2ce8 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs @@ -152,6 +152,21 @@ 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) + { + // A typical application will take more action here. + Console.WriteLine("{0} Exception caught.", exception.ToString()); + } + + /// /// Usage /// @@ -259,8 +274,17 @@ namespace Org.Apache.Qpid.Messaging.Examples // // Close the receiver and the connection. // - receiver.Close(); - connection.Close(); + try + { + receiver.Close(); + connection.Close(); + } + catch (Exception exception) + { + // receiver or connection may throw if they closed in error. + // A typical application will take more action here. + Console.WriteLine("{0} Closing exception caught.", exception.ToString()); + } return 0; } } diff --git a/cpp/bindings/qpid/dotnet/msvc9/org.apache.qpid.messaging.sessionreceiver.sln b/cpp/bindings/qpid/dotnet/msvc9/org.apache.qpid.messaging.sessionreceiver.sln index 9ed7d4df3a..112511e5e5 100644 --- a/cpp/bindings/qpid/dotnet/msvc9/org.apache.qpid.messaging.sessionreceiver.sln +++ b/cpp/bindings/qpid/dotnet/msvc9/org.apache.qpid.messaging.sessionreceiver.sln @@ -21,7 +21,7 @@ Microsoft Visual Studio Solution File, Format Version 10.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Org.Apache.Qpid.Messaging", "..\src\msvc9\org.apache.qpid.messaging.vcproj", "{AA5A3B83-5F98-406D-A01C-5A921467A57D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "org.apache.qpid.messaging.sessionreceiver", "..\src\msvc9\sessionreceiver\org.apache.qpid.messaging.sessionreceiver.csproj", "{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "org.apache.qpid.messaging.sessionreceiver", "..\src\sessionreceiver\msvc9\org.apache.qpid.messaging.sessionreceiver.csproj", "{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index bbd7dd4c52..43bb7dd3cb 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -344,9 +344,34 @@ namespace Messaging { void Receiver::Close() { - msclr::lock lk(privateLock); - ThrowIfDisposed(); + System::Exception ^ newException = nullptr; + Message ^ newMessage = nullptr; - nativeObjPtr->close(); + try + { + msclr::lock lk(privateLock); + ThrowIfDisposed(); + + nativeObjPtr->close(); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + finally + { + if (newException != nullptr) + { + if (newMessage != nullptr) + { + delete newMessage; + } + } + } + if (newException != nullptr) + { + throw newException; + } } }}}} diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs b/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs index 680732068f..a15a8d60fe 100644 --- a/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs +++ b/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