activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1028404 - /activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
Date Thu, 28 Oct 2010 18:00:59 GMT
Author: tabish
Date: Thu Oct 28 18:00:59 2010
New Revision: 1028404

URL: http://svn.apache.org/viewvc?rev=1028404&view=rev
Log:
Set the message type field properly in the consumer receive methods.

Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp?rev=1028404&r1=1028403&r2=1028404&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp Thu Oct 28 18:00:59
2010
@@ -20,6 +20,12 @@
 #include <Config.h>
 #include <types/CMS_Types.h>
 
+#include <cms/Message.h>
+#include <cms/TextMessage.h>
+#include <cms/BytesMessage.h>
+#include <cms/StreamMessage.h>
+#include <cms/MapMessage.h>
+
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -127,10 +133,25 @@ cms_status consumerReceive(CMS_MessageCo
 
             cms::Message* msg = consumer->consumer->receive();
 
-            wrapper->message = msg;
-            // TODO set the message type
+            if(msg != NULL) {
+                wrapper->message = msg;
+
+                if(dynamic_cast<cms::TextMessage*>(msg) != NULL) {
+                   wrapper->type = CMS_TEXT_MESSAGE;
+                } else if(dynamic_cast<cms::BytesMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_BYTES_MESSAGE;
+                } else if(dynamic_cast<cms::MapMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_MAP_MESSAGE;
+                } else if(dynamic_cast<cms::StreamMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_STREAM_MESSAAGE;
+                } else {
+                    wrapper->type = CMS_MESSAGE;
+                }
 
-            *message = wrapper.release();
+                *message = wrapper.release();
+            } else {
+                *message = NULL;
+            }
 
         } catch(...) {
             result = CMS_ERROR;
@@ -155,7 +176,19 @@ cms_status consumerReceiveWithTimeout(CM
 
             if (msg != NULL) {
                 wrapper->message = msg;
-                // TODO set the message type
+
+                if(dynamic_cast<cms::TextMessage*>(msg) != NULL) {
+                   wrapper->type = CMS_TEXT_MESSAGE;
+                } else if(dynamic_cast<cms::BytesMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_BYTES_MESSAGE;
+                } else if(dynamic_cast<cms::MapMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_MAP_MESSAGE;
+                } else if(dynamic_cast<cms::StreamMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_STREAM_MESSAAGE;
+                } else {
+                    wrapper->type = CMS_MESSAGE;
+                }
+
                 *message = wrapper.release();
             } else {
                 *message = NULL;
@@ -185,7 +218,17 @@ cms_status consumerReceiveNoWait(CMS_Mes
             if (msg != NULL) {
                 wrapper->message = msg;
 
-                // TODO set the message type
+                if(dynamic_cast<cms::TextMessage*>(msg) != NULL) {
+                   wrapper->type = CMS_TEXT_MESSAGE;
+                } else if(dynamic_cast<cms::BytesMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_BYTES_MESSAGE;
+                } else if(dynamic_cast<cms::MapMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_MAP_MESSAGE;
+                } else if(dynamic_cast<cms::StreamMessage*>(msg) != NULL) {
+                    wrapper->type = CMS_STREAM_MESSAAGE;
+                } else {
+                    wrapper->type = CMS_MESSAGE;
+                }
 
                 *message = wrapper.release();
             } else {



Mime
View raw message