[PATCH 13/50] [mama] mamaDQPublisher_sendReplyWithHandle


Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This method allows applications to use a reply handle rather than detaching and
holding on to the original message. Since OpenMAMA attempts to reuse messages
this may improve performance for some applications.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/dqpublisher.c | 105 ++++++++++++++++++++++++++++++++++-
mama/c_cpp/src/c/mama/dqpublisher.h | 5 ++
2 files changed, 107 insertions(+), 3 deletions(-)

diff --git a/mama/c_cpp/src/c/dqpublisher.c b/mama/c_cpp/src/c/dqpublisher.c
index a875399..4363a1f 100644
--- a/mama/c_cpp/src/c/dqpublisher.c
+++ b/mama/c_cpp/src/c/dqpublisher.c
@@ -157,17 +157,116 @@ mama_status mamaDQPublisher_sendReply (mamaDQPublisher pub,
{
mamaDQPublisherImpl* impl = (mamaDQPublisherImpl*) (pub);

- mamaMsg_updateU8(reply, NULL, MamaFieldMsgStatus.mFid, impl->mStatus);
+ if(MAMA_STATUS_OK != mamaMsg_updateU8(reply,MamaFieldMsgStatus.mName,
+ MamaFieldMsgStatus.mFid, impl->mStatus))
+ {
+ mamaMsg_updateI16(reply,MamaFieldMsgStatus.mName,
+ MamaFieldMsgStatus.mFid, impl->mStatus);
+ }

if (impl->mSenderId != 0)
- mamaMsg_updateU64(reply, NULL, MamaFieldSenderId.mFid, impl->mSenderId);
+ {
+ mamaMsgField senderIdField = NULL;
+ if (MAMA_STATUS_OK == mamaMsg_getField(reply,
+ MamaFieldSenderId.mName, MamaFieldSenderId.mFid,
+ &senderIdField))
+ {
+ mamaFieldType senderIdType = MAMA_FIELD_TYPE_UNKNOWN;
+ if (MAMA_STATUS_OK == mamaMsgField_getType(senderIdField,
+ &senderIdType))
+ {
+ switch(senderIdType)
+ {
+ case MAMA_FIELD_TYPE_U16:
+ mamaMsgField_updateU16(senderIdField,
+ (mama_u16_t)impl->mSenderId);
+ break;
+
+ case MAMA_FIELD_TYPE_U32:
+ mamaMsgField_updateU32(senderIdField,
+ (mama_u32_t)impl->mSenderId);
+ break;
+
+ case MAMA_FIELD_TYPE_U64:
+ default:
+ mamaMsgField_updateU64(senderIdField,
+ impl->mSenderId);
+ break;
+ }
+ }
+ }
+ else
+ mamaMsg_addU64(reply, MamaFieldSenderId.mName,
+ MamaFieldSenderId.mFid, impl->mSenderId);
+ }

if (impl->mSeqNum != 0)
- mamaMsg_updateU32(reply, NULL, MamaFieldSeqNum.mFid, impl->mSeqNum);
+ {
+ mamaMsg_updateU32(reply, MamaFieldSeqNum.mName, MamaFieldSeqNum.mFid,
+ impl->mSeqNum);
+ }

return (mamaPublisher_sendReplyToInbox (impl->mPublisher, request, reply));
}

+mama_status mamaDQPublisher_sendReplyWithHandle (mamaDQPublisher pub,
+ mamaMsgReply replyAddress,
+ mamaMsg reply)
+{
+ mamaDQPublisherImpl* impl = (mamaDQPublisherImpl*) (pub);
+
+ if(MAMA_STATUS_OK != mamaMsg_updateU8(reply,MamaFieldMsgStatus.mName,
+ MamaFieldMsgStatus.mFid, impl->mStatus))
+ {
+ mamaMsg_updateI16(reply,MamaFieldMsgStatus.mName,
+ MamaFieldMsgStatus.mFid, impl->mStatus);
+ }
+
+ if (impl->mSenderId != 0)
+ {
+ mamaMsgField senderIdField = NULL;
+ if (MAMA_STATUS_OK == mamaMsg_getField(reply,
+ MamaFieldSenderId.mName, MamaFieldSenderId.mFid,
+ &senderIdField))
+ {
+ mamaFieldType senderIdType = MAMA_FIELD_TYPE_UNKNOWN;
+ if (MAMA_STATUS_OK == mamaMsgField_getType(senderIdField,
+ &senderIdType))
+ {
+ switch(senderIdType)
+ {
+ case MAMA_FIELD_TYPE_U16:
+ mamaMsgField_updateU16(senderIdField,
+ (mama_u16_t)impl->mSenderId);
+ break;
+
+ case MAMA_FIELD_TYPE_U32:
+ mamaMsgField_updateU32(senderIdField,
+ (mama_u32_t)impl->mSenderId);
+ break;
+
+ case MAMA_FIELD_TYPE_U64:
+ default:
+ mamaMsgField_updateU64(senderIdField,
+ impl->mSenderId);
+ break;
+ }
+ }
+ }
+ else
+ mamaMsg_addU64(reply, MamaFieldSenderId.mName,
+ MamaFieldSenderId.mFid, impl->mSenderId);
+ }
+
+ if (impl->mSeqNum != 0)
+ {
+ mamaMsg_updateU32(reply, MamaFieldSeqNum.mName, MamaFieldSeqNum.mFid,
+ impl->mSeqNum);
+ }
+
+ return (mamaPublisher_sendReplyToInboxHandle (impl->mPublisher,
+ replyAddress, reply));
+}

void mamaDQPublisher_destroy (mamaDQPublisher pub)
{
diff --git a/mama/c_cpp/src/c/mama/dqpublisher.h b/mama/c_cpp/src/c/mama/dqpublisher.h
index f792656..c8ae155 100644
--- a/mama/c_cpp/src/c/mama/dqpublisher.h
+++ b/mama/c_cpp/src/c/mama/dqpublisher.h
@@ -81,6 +81,11 @@ mamaDQPublisher_sendReply (mamaDQPublisher pub, mamaMsg request,


MAMAExpDLL
+extern mama_status
+mamaDQPublisher_sendReplyWithHandle (mamaDQPublisher pub,
+ mamaMsgReply replyAddress,
+ mamaMsg reply);
+MAMAExpDLL
extern void
mamaDQPublisher_destroy (mamaDQPublisher pub);

--
1.7.7.6