activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1025756 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Message.cpp CMS_Message.h
Date Wed, 20 Oct 2010 21:16:37 GMT
Author: tabish
Date: Wed Oct 20 21:16:35 2010
New Revision: 1025756

URL: http://svn.apache.org/viewvc?rev=1025756&view=rev
Log:
Add create methods for all the CMS Message types.

Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp?rev=1025756&r1=1025755&r2=1025756&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp Wed Oct 20 21:16:35
2010
@@ -27,6 +27,30 @@
 #include <memory>
 
 ////////////////////////////////////////////////////////////////////////////////
+cms_status createMessage(CMS_Session* session, CMS_Message** message) {
+
+    cms_status result = CMS_SUCCESS;
+    std::auto_ptr<CMS_Message> wrapper( new CMS_Message );
+
+    try{
+
+        if (session == NULL) {
+            result = CMS_ERROR;
+        } else {
+
+            wrapper->message = session->session->createMessage();
+            wrapper->type = CMS_MESSAGE;
+            *message = wrapper.release();
+        }
+
+    } catch(...) {
+        result = CMS_ERROR;
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 cms_status createTextMessage(CMS_Session* session, CMS_Message** message, const char* body)
{
 
     cms_status result = CMS_SUCCESS;
@@ -56,6 +80,83 @@ cms_status createTextMessage(CMS_Session
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+cms_status createBytesMessage(CMS_Session* session, CMS_Message** message, unsigned char*
body, int length) {
+
+    cms_status result = CMS_SUCCESS;
+    std::auto_ptr<CMS_Message> wrapper( new CMS_Message );
+
+    try{
+
+        if (session == NULL) {
+            result = CMS_ERROR;
+        } else {
+
+            if (body == NULL) {
+                wrapper->message = session->session->createBytesMessage();
+            } else {
+                wrapper->message = session->session->createBytesMessage(body, length);
+            }
+
+            wrapper->type = CMS_BYTES_MESSAGE;
+            *message = wrapper.release();
+        }
+
+    } catch(...) {
+        result = CMS_ERROR;
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status createMapMessage(CMS_Session* session, CMS_Message** message) {
+
+    cms_status result = CMS_SUCCESS;
+    std::auto_ptr<CMS_Message> wrapper( new CMS_Message );
+
+    try{
+
+        if (session == NULL) {
+            result = CMS_ERROR;
+        } else {
+
+            wrapper->message = session->session->createMapMessage();
+            wrapper->type = CMS_MAP_MESSAGE;
+            *message = wrapper.release();
+        }
+
+    } catch(...) {
+        result = CMS_ERROR;
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status createStreamMessage(CMS_Session* session, CMS_Message** message) {
+
+    cms_status result = CMS_SUCCESS;
+    std::auto_ptr<CMS_Message> wrapper( new CMS_Message );
+
+    try{
+
+        if (session == NULL) {
+            result = CMS_ERROR;
+        } else {
+
+            wrapper->message = session->session->createStreamMessage();
+            wrapper->type = CMS_STREAM_MESSAAGE;
+            *message = wrapper.release();
+        }
+
+    } catch(...) {
+        result = CMS_ERROR;
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 cms_status destroyMessage(CMS_Message* message) {
 
     cms_status result = CMS_SUCCESS;

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h?rev=1025756&r1=1025755&r2=1025756&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h Wed Oct 20 21:16:35 2010
@@ -25,8 +25,21 @@ extern "C" {
 #endif
 
 /**
+ * Creates a New Message from the given Session instance.
+ *
+ * @param session
+ *      The Session to use to create the new Message
+ * @param message
+ *      The address of the location to store the new Message instance.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createMessage(CMS_Session* session, CMS_Message** message);
+
+/**
  * Creates a New Text Message from the given Session instance, if set the value of the
- * body parameter is assigned as the body of the Text Message.
+ * body parameter is copied as the body of the Text Message.  The caller retains ownership
+ * of the body array and must handle its deallocation.
  *
  * @param session
  *      The Session to use to create the new Text Message
@@ -40,6 +53,49 @@ extern "C" {
 cms_status createTextMessage(CMS_Session* session, CMS_Message** message, const char* body);
 
 /**
+ * Creates a New Bytes Message from the given Session instance.  If set the value of the
+ * body parameter is copied as the body of the Bytes Message.  The length parameter defines
+ * how many bytes are copied from the body array into the Bytes Message.  The caller retains
+ * ownership of the body array and must handle its deallocation.
+ *
+ * @param session
+ *      The Session to use to create the new Message
+ * @param message
+ *      The address of the location to store the new Message instance.
+ * @param body
+ *      The bytes that should be copied to the body of the Bytes Message.
+ * @param length
+ *      The number of bytes contained in the body array.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createBytesMessage(CMS_Session* session, CMS_Message** message, unsigned char*
body, int length);
+
+/**
+ * Creates a New Map Message from the given Session instance.
+ *
+ * @param session
+ *      The Session to use to create the new Message
+ * @param message
+ *      The address of the location to store the new Message instance.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createMapMessage(CMS_Session* session, CMS_Message** message);
+
+/**
+ * Creates a New Stream Message from the given Session instance.
+ *
+ * @param session
+ *      The Session to use to create the new Message
+ * @param message
+ *      The address of the location to store the new Message instance.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createStreamMessage(CMS_Session* session, CMS_Message** message);
+
+/**
  * Destroy the given Message instance.
  *
  * @param message



Mime
View raw message