diff options
| author | Charles E. Rolke <chug@apache.org> | 2011-01-03 16:59:39 +0000 |
|---|---|---|
| committer | Charles E. Rolke <chug@apache.org> | 2011-01-03 16:59:39 +0000 |
| commit | 636c9761ecf5f680112d330f00e8c39bcb7d9394 (patch) | |
| tree | 5c56dbec6d7558ca2e60dc603629b2e3961e1272 /qpid/cpp | |
| parent | d1563e134514d9c5d70f8d71b5684702f80bfaf4 (diff) | |
| download | qpid-python-636c9761ecf5f680112d330f00e8c39bcb7d9394.tar.gz | |
.NET Binding for Qpid Messaging:
Add the boolean variation of Get() and Fetch().
Modify drain example to use the boolean Fetch.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1054684 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
3 files changed, 79 insertions, 44 deletions
diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs index 04a0764f7c..da8218bbf7 100644 --- a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs +++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs @@ -43,9 +43,9 @@ namespace Org.Apache.Qpid.Messaging.Examples { Duration timeout = options.Forever ?
DurationConstants.FORVER :
DurationConstants.SECOND * options.Timeout;
- Message message;
+ Message message = new Message();
- while ((message = receiver.Fetch(timeout)) != null)
+ while (receiver.Fetch(ref message, timeout))
{
Dictionary<string, object> properties = new Dictionary<string, object>();
properties = message.Properties;
diff --git a/qpid/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/qpid/cpp/bindings/qpid/dotnet/src/Receiver.cpp index ea612861e5..4c9062866d 100644 --- a/qpid/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/qpid/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -121,24 +121,43 @@ namespace Messaging { //
// Get(message)
//
- // TBD
- //bool Receiver::Get(Message ^ mmsgp)
- //{
- // return Get(mmsgp, DurationConstants::FORVER);
- //}
- //
- //bool Receiver::Get(Message ^ mmsgp, Duration ^ durationp)
- //{
- // ::qpid::messaging::Duration dur((*durationp).Milliseconds);
- //
- // ::qpid::messaging::Message tmpMsg;
- //
- // bool result = receiverp->Receiver::get(tmpMsg, dur);
- //
- // mmsgp = gcnew Message(tmpMsg);
- //
- // return result;
- //}
+ bool Receiver::Get(Message ^% mmsgp)
+ {
+ return Get(mmsgp, DurationConstants::FORVER);
+ }
+
+ bool Receiver::Get(Message ^% mmsgp, Duration ^ durationp)
+ {
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ ::qpid::messaging::Message tmpMsg;
+
+ bool result = receiverp->Receiver::get(tmpMsg, dur);
+
+ if (result)
+ {
+ mmsgp = gcnew Message(tmpMsg);
+ }
+
+ return result;
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
+
+ return false;
+ }
//
// message = Get()
@@ -192,24 +211,42 @@ namespace Messaging { //
// Fetch(message)
//
- // TBD
- //bool Receiver::Fetch(Message ^ mmsgp)
- //{
- // return Fetch(mmsgp, DurationConstants::FORVER);
- //}
- //
- //bool Receiver::Fetch(Message ^ mmsgp, Duration ^ durationp)
- //{
- // ::qpid::messaging::Duration dur((*durationp).Milliseconds);
- //
- // ::qpid::messaging::Message tmpMsg;
- //
- // bool result = receiverp->Receiver::fetch(tmpMsg, dur);
- //
- // mmsgp = gcnew Message(tmpMsg);
- //
- // return result;
- //}
+ bool Receiver::Fetch(Message ^% mmsgp)
+ {
+ return Fetch(mmsgp, DurationConstants::FORVER);
+ }
+
+ bool Receiver::Fetch(Message ^% mmsgp, Duration ^ durationp)
+ {
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ ::qpid::messaging::Message tmpMsg;
+
+ bool result = receiverp->Receiver::fetch(tmpMsg, dur);
+
+ if (result)
+ {
+ mmsgp = gcnew Message(tmpMsg);
+ }
+
+ return result;
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
+
+ return false;
+ }
//
diff --git a/qpid/cpp/bindings/qpid/dotnet/src/Receiver.h b/qpid/cpp/bindings/qpid/dotnet/src/Receiver.h index ae32f6f4d3..123c266b55 100644 --- a/qpid/cpp/bindings/qpid/dotnet/src/Receiver.h +++ b/qpid/cpp/bindings/qpid/dotnet/src/Receiver.h @@ -99,18 +99,16 @@ namespace Messaging { }
// Get(message)
- // TBD
- //bool Get(Message ^ mmsgp);
- //bool Get(Message ^ mmsgp, Duration ^ durationp);
+ bool Get(Message ^% mmsgp);
+ bool Get(Message ^% mmsgp, Duration ^ durationp);
// message = Get()
Message ^ Get();
Message ^ Get(Duration ^ durationp);
// Fetch(message)
- // TBD
- //bool Fetch(Message ^ mmsgp);
- //bool Fetch(Message ^ mmsgp, Duration ^ duration);
+ bool Fetch(Message ^% mmsgp);
+ bool Fetch(Message ^% mmsgp, Duration ^ duration);
// message = Fetch()
Message ^ Fetch();
|
