activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1027727 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Message.cpp CMS_Message.h
Date Tue, 26 Oct 2010 20:19:37 GMT
Author: tabish
Date: Tue Oct 26 20:19:36 2010
New Revision: 1027727

URL: http://svn.apache.org/viewvc?rev=1027727&view=rev
Log:
Completes the API for all the generic CMS Message methods.

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=1027727&r1=1027726&r2=1027727&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 Tue Oct 26 20:19:36
2010
@@ -496,7 +496,7 @@ cms_status getMessageStringProperty(CMS_
             if(!property.empty()) {
 
                 std::size_t pos = 0;
-                for(; pos < property.size() && pos < size - 1; ++pos) {
+                for(; pos < property.size() && pos < (std::size_t)size - 1;
++pos) {
                     value[pos] = property.at(pos);
                 }
 
@@ -700,3 +700,469 @@ cms_status setStringProperty(CMS_Message
 
     return result;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageCorrelationID(CMS_Message* message, char* correlationId, int size)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && correlationId != NULL && size > 0) {
+
+        try{
+
+            std::string id = message->message->getCMSCorrelationID();
+
+            if(!id.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < id.size() && pos < (std::size_t)size - 1; ++pos)
{
+                    correlationId[pos] = id.at(pos);
+                }
+
+                correlationId[pos] = '\0';
+            } else {
+                correlationId[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            correlationId[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            correlationId[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageCorrelationID(CMS_Message* message, const char* correlationId) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && correlationId != NULL) {
+
+        try{
+
+            if(strlen(correlationId) > 0) {
+                message->message->setCMSCorrelationID(correlationId);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageDeliveryMode(CMS_Message* message, int* mode) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && mode != NULL) {
+
+        try{
+            *mode = message->message->getCMSDeliveryMode();
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageDeliveryMode(CMS_Message* message, int mode) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+            message->message->setCMSDeliveryMode(mode);
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageDestination(CMS_Message* message, CMS_Destination** destination)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+
+            std::auto_ptr<CMS_Destination> wrapper( new CMS_Destination );
+
+            const cms::Destination* dest = message->message->getCMSDestination();
+
+            if (dest != NULL) {
+                wrapper->destination = dest->clone();
+                *destination = wrapper.release();
+            } else {
+                *destination = NULL;
+            }
+
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageDestination(CMS_Message* message, CMS_Destination* destination) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+
+            if (destination != NULL) {
+                message->message->setCMSDestination(destination->destination->clone());
+            } else {
+                message->message->setCMSDestination(NULL);
+            }
+
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageExpiration(CMS_Message* message, long long* expiration) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && expiration != NULL) {
+
+        try{
+            *expiration = message->message->getCMSExpiration();
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageExpiration(CMS_Message* message, long long expiration) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+            message->message->setCMSExpiration(expiration);
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageMessageID(CMS_Message* message, char* messageId, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && messageId != NULL && size > 0) {
+
+        try{
+
+            std::string id = message->message->getCMSMessageID();
+
+            if(!id.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < id.size() && pos < (std::size_t)size - 1; ++pos)
{
+                    messageId[pos] = id.at(pos);
+                }
+
+                messageId[pos] = '\0';
+            } else {
+                messageId[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            messageId[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            messageId[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageMessageID(CMS_Message* message, const char* messageId) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && messageId != NULL) {
+
+        try{
+
+            if(strlen(messageId) > 0) {
+                message->message->setCMSMessageID(messageId);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessagePriority(CMS_Message* message, int* priority) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && priority != NULL) {
+
+        try{
+            *priority = message->message->getCMSPriority();
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessagePriority(CMS_Message* message, int priority) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+            message->message->setCMSPriority(priority);
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageRedelivered(CMS_Message* message, int* redelivered) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && redelivered != NULL) {
+
+        try{
+            *redelivered = (int) message->message->getCMSRedelivered();
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageRedelivered(CMS_Message* message, int redelivered) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+            message->message->setCMSRedelivered(redelivered == 0 ? false : true);
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageReplyTo(CMS_Message* message, CMS_Destination** destination) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+
+            std::auto_ptr<CMS_Destination> wrapper( new CMS_Destination );
+
+            const cms::Destination* dest = message->message->getCMSReplyTo();
+
+            if (dest != NULL) {
+                wrapper->destination = dest->clone();
+                *destination = wrapper.release();
+            } else {
+                *destination = NULL;
+            }
+
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageReplyTo(CMS_Message* message, CMS_Destination* destination) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+
+            if (destination != NULL) {
+                message->message->setCMSReplyTo(destination->destination->clone());
+            } else {
+                message->message->setCMSReplyTo(NULL);
+            }
+
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageTimestamp(CMS_Message* message, long long* timeStamp) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && timeStamp != NULL) {
+
+        try{
+            *timeStamp = message->message->getCMSTimestamp();
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageTimestamp(CMS_Message* message, long long timeStamp) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        try{
+            message->message->setCMSTimestamp(timeStamp);
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getCMSMessageType(CMS_Message* message, char* type, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && type != NULL && size > 0) {
+
+        try{
+
+            std::string typeVal = message->message->getCMSType();
+
+            if(!typeVal.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < typeVal.size() && pos < (std::size_t)size - 1;
++pos) {
+                    type[pos] = typeVal.at(pos);
+                }
+
+                type[pos] = '\0';
+            } else {
+                type[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            type[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            type[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setCMSMessageType(CMS_Message* message, const char* type) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && type != NULL) {
+
+        try{
+
+            if(strlen(type) > 0) {
+                message->message->setCMSType(type);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}

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=1027727&r1=1027726&r2=1027727&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 Tue Oct 26 20:19:36 2010
@@ -412,6 +412,254 @@ cms_status setShortProperty(CMS_Message*
  */
 cms_status setStringProperty(CMS_Message* message, const char* key, const char* value);
 
+/**
+ * Gets the Correlation Id that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the correlation Id from.
+ * @param correlationId
+ *      The character array to write the correlation id to.
+ * @param size
+ *      The size of the passed correlationId character array.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageCorrelationID(CMS_Message* message, char* correlationId, int size);
+
+/**
+ * Sets the Correlation Id assigned to this Message.
+ *
+ * @param message
+ *      The message to assign the correlation Id to.
+ * @param correlationId
+ *      The character array to copy the correlation id from and assign to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageCorrelationID(CMS_Message* message, const char* correlationId);
+
+/**
+ * Gets the Delivery Mode that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the delivery mode from.
+ * @param mode
+ *      The address where the value of the retrieved option is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageDeliveryMode(CMS_Message* message, int* mode);
+
+/**
+ * Sets the Delivery Mode that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the delivery mode on.
+ * @param mode
+ *      The new value that should be applied to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageDeliveryMode(CMS_Message* message, int mode);
+
+/**
+ * Gets the Destination that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the Destination from.
+ * @param destination
+ *      The address where the value of the retrieved value is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageDestination(CMS_Message* message, CMS_Destination** destination);
+
+/**
+ * Sets the Destination that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the Destination to.
+ * @param destination
+ *      The new value that should be applied to the Message, the destination is cloned, caller
+ *      retains ownership of the original value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageDestination(CMS_Message* message, CMS_Destination* destination);
+
+/**
+ * Gets the Message expiration time that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the expiration time from.
+ * @param expiration
+ *      The address where the value of the retrieved option is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageExpiration(CMS_Message* message, long long* expiration);
+
+/**
+ * Sets the Expiration time that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the expiration time on.
+ * @param expiration
+ *      The new value that should be applied to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageExpiration(CMS_Message* message, long long expiration);
+
+/**
+ * Gets the Message Id that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the message Id from.
+ * @param messageId
+ *      The character array to write the message id to.
+ * @param size
+ *      The size of the passed messageId character array.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageMessageID(CMS_Message* message, char* messageId, int size);
+
+/**
+ * Sets the Message Id assigned to this Message.
+ *
+ * @param message
+ *      The message to assign the correlation Id to.
+ * @param messageId
+ *      The character array to copy the message id from and assign to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageMessageID(CMS_Message* message, const char* messageId);
+
+/**
+ * Gets the Message Priority that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the priority from.
+ * @param priority
+ *      The address where the value of the retrieved option is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessagePriority(CMS_Message* message, int* priority);
+
+/**
+ * Sets the Message priority that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the priority on.
+ * @param priority
+ *      The new value that should be applied to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessagePriority(CMS_Message* message, int priority);
+
+/**
+ * Gets the Message Redelivered flag that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the redelivered value from.
+ * @param redelivered
+ *      The address where the value of the retrieved option is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageRedelivered(CMS_Message* message, int* redelivered);
+
+/**
+ * Sets the Redelivered flag that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the redelivered value on.
+ * @param redelivered
+ *      The new value that should be applied to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageRedelivered(CMS_Message* message, int redelivered);
+
+/**
+ * Gets the Reply To Destination that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the Reply To Destination from.
+ * @param destination
+ *      The address where the value of the retrieved value is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageReplyTo(CMS_Message* message, CMS_Destination** destination);
+
+/**
+ * Sets the Reply To Destination that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the Destination to.
+ * @param destination
+ *      The new value that should be applied to the Message, the destination is cloned, caller
+ *      retains ownership of the original value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageReplyTo(CMS_Message* message, CMS_Destination* destination);
+
+/**
+ * Gets the Message time-stamp that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the time-stamp value from.
+ * @param timeStamp
+ *      The address where the value of the retrieved option is to be written.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageTimestamp(CMS_Message* message, long long* timeStamp);
+
+/**
+ * Sets the time stamp that is assigned to this Message.
+ *
+ * @param message
+ *      The message to set the time stamp on.
+ * @param timeStamp
+ *      The new value that should be applied to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageTimestamp(CMS_Message* message, long long timeStamp);
+
+/**
+ * Gets the Message Type that is assigned to this Message.
+ *
+ * @param message
+ *      The message to retrieve the message type from.
+ * @param type
+ *      The character array to write the message type to.
+ * @param size
+ *      The size of the passed type character array.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getCMSMessageType(CMS_Message* message, char* type, int size);
+
+/**
+ * Sets the Message Type assigned to this Message.
+ *
+ * @param message
+ *      The message to assign the type to.
+ * @param type
+ *      The character array to copy the message type from and assign to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setCMSMessageType(CMS_Message* message, const char* type);
+
 #ifdef __cplusplus
 }
 #endif



Mime
View raw message