diff options
| author | Ted Ross <tross@apache.org> | 2010-05-28 18:09:10 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-05-28 18:09:10 +0000 |
| commit | 947b1491d7a39c87c4560126a6e50646aa2a2b24 (patch) | |
| tree | 19a5c7ac347d807125f8352ef5f2d41810d79281 /cpp/bindings/qpid/dotnet/src/Receiver.cpp | |
| parent | 8d317104053b8258380c47af8d792517c4da10b7 (diff) | |
| download | qpid-python-947b1491d7a39c87c4560126a6e50646aa2a2b24.tar.gz | |
QPID-2628 - Patch from Chuck Rolke
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@949245 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/dotnet/src/Receiver.cpp')
| -rw-r--r-- | cpp/bindings/qpid/dotnet/src/Receiver.cpp | 145 |
1 files changed, 127 insertions, 18 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index 3902ea75c2..d647315620 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -26,11 +26,13 @@ #include "qpid/messaging/Receiver.h"
#include "qpid/messaging/Session.h"
#include "qpid/messaging/Message.h"
+#include "qpid/messaging/exceptions.h"
#include "Receiver.h"
#include "Session.h"
#include "Message.h"
#include "Duration.h"
+#include "QpidException.h"
namespace org {
namespace apache {
@@ -82,56 +84,163 @@ namespace messaging { }
}
+ //
+ // get(message)
+ //
bool Receiver::get(Message ^ mmsgp)
{
- return receiverp->Receiver::get(*((*mmsgp).messagep));
+ return get(mmsgp, DurationConstants::FORVER);
}
bool Receiver::get(Message ^ mmsgp, Duration ^ durationp)
{
- return receiverp->Receiver::get(*((*mmsgp).messagep),
- *((*durationp).durationp));
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ return receiverp->Receiver::get(*(mmsgp->messagep), dur);
}
+ //
+ // message = get()
+ //
+ Message ^ Receiver::get()
+ {
+ return get(DurationConstants::FORVER);
+ }
+
+
Message ^ Receiver::get(Duration ^ durationp)
{
- // allocate a message
- ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Message * msgp = NULL;
+ Message ^ newMessage = nullptr;
- // get the message
- *msgp = receiverp->::qpid::messaging::Receiver::get(*((*durationp).durationp));
+ try
+ {
+ // allocate a message
+ msgp = new ::qpid::messaging::Message;
+
+ // translate the duration
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
- // create new managed message with received message embedded in it
- Message ^ newMessage = gcnew Message(msgp);
+ // get the message
+ *msgp = receiverp->::qpid::messaging::Receiver::get(dur);
+
+ // create new managed message with received message embedded in it
+ newMessage = gcnew Message(msgp);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Receiver:get unknown error");
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (msgp != NULL)
+ {
+ delete msgp;
+ }
+
+ throw newException;
+ }
+ }
return newMessage;
}
+ //
+ // fetch(message)
+ //
bool Receiver::fetch(Message ^ mmsgp)
{
- return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep));
+ return fetch(mmsgp, DurationConstants::FORVER);
}
bool Receiver::fetch(Message ^ mmsgp, Duration ^ durationp)
{
- return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep),
- *((*durationp).durationp));
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep), dur);
}
+
+ //
+ // message = fetch()
+ //
+
+ Message ^ Receiver::fetch()
+ {
+ return fetch(DurationConstants::FORVER);
+ }
+
Message ^ Receiver::fetch(Duration ^ durationp)
{
- // allocate a message
- ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Message * msgp = NULL;
+ Message ^ newMessage = nullptr;
+
+ try
+ {
+ // allocate a message
+ ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+
+ // translate the duration
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ // get the message
+ *msgp = receiverp->::qpid::messaging::Receiver::fetch(dur);
+
+ // create new managed message with received message embedded in it
+ newMessage = gcnew Message(msgp);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Receiver:fetch unknown error");
- // get the message
- *msgp = receiverp->::qpid::messaging::Receiver::fetch(*((*durationp).durationp));
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (msgp != NULL)
+ {
+ delete msgp;
+ }
- // create new managed message with received message embedded in it
- Message ^ newMessage = gcnew Message(msgp);
+ throw newException;
+ }
+ }
return newMessage;
}
+ void Receiver::setCapacity(System::UInt32 capacity)
+ {
+ receiverp->setCapacity(capacity);
+ }
+
System::UInt32 Receiver::getCapacity()
{
return receiverp->getCapacity();
|
