Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
Representation of a message. More...
#include <qpid/messaging/Message.h>
Public Member Functions | |
Message (qpid::types::Variant &) | |
Message (const std::string &bytes=std::string()) | |
Message (const char *, size_t) | |
Message (const Message &) | |
~Message () | |
Message & | operator= (const Message &) |
void | setReplyTo (const Address &) |
const Address & | getReplyTo () const |
void | setSubject (const std::string &) |
const std::string & | getSubject () const |
void | setContentType (const std::string &) |
Set the content type (i.e. More... | |
const std::string & | getContentType () const |
Returns the content type (i.e. More... | |
void | setMessageId (const std::string &) |
Set an application defined identifier for the message. More... | |
const std::string & | getMessageId () const |
void | setUserId (const std::string &) |
Sets the user id of the message. More... | |
const std::string & | getUserId () const |
void | setCorrelationId (const std::string &) |
Can be used to set application specific correlation identifiers as part of a protocol for message exchange patterns. More... | |
const std::string & | getCorrelationId () const |
void | setPriority (uint8_t) |
Sets a priority level on the message. More... | |
uint8_t | getPriority () const |
void | setTtl (Duration ttl) |
Set the time to live for this message in milliseconds. More... | |
Duration | getTtl () const |
Get the time to live for this message in milliseconds. More... | |
void | setDurable (bool durable) |
Mark the message as durable. More... | |
bool | getDurable () const |
bool | getRedelivered () const |
The redelivered flag if set implies that the message may have been previously delivered and thus is a hint to the application or messaging infrastructure that if de-duplication is required this message should be examined to determine if it is a duplicate. More... | |
void | setRedelivered (bool) |
Can be used to provide a hint to the application or messaging infrastructure that if de-duplication is required this message should be examined to determine if it is a duplicate. More... | |
const qpid::types::Variant::Map & | getProperties () const |
In addition to a payload (i.e. More... | |
qpid::types::Variant::Map & | getProperties () |
void | setProperties (const qpid::types::Variant::Map &) |
void | setContent (const std::string &) |
Set the content to the data held in the string parameter. More... | |
void | setContent (const char *chars, size_t count) |
Copy count bytes from the region pointed to by chars as the message content. More... | |
std::string | getContent () const |
Get the content as a std::string. More... | |
std::string | getContentBytes () const |
Get the content as raw bytes (an alias for getContent() More... | |
void | setContentBytes (const std::string &) |
Set the content as raw bytes (an alias for setContent() More... | |
qpid::types::Variant & | getContentObject () |
Get the content as a Variant, which can represent an object of different types. More... | |
const qpid::types::Variant & | getContentObject () const |
Get the content as a Variant, which can represent an object of different types. More... | |
void | setContentObject (const qpid::types::Variant &) |
Set the content using a Variant, which can represent an object of different types. More... | |
const char * | getContentPtr () const |
Get a const pointer to the start of the content data. More... | |
size_t | getContentSize () const |
Get the size of content in bytes. More... | |
void | setProperty (const std::string &, const qpid::types::Variant &) |
qpid::messaging::Message::Message | ( | qpid::types::Variant & | ) |
qpid::messaging::Message::Message | ( | const std::string & | bytes = std::string() | ) |
qpid::messaging::Message::Message | ( | const char * | , |
size_t | |||
) |
qpid::messaging::Message::Message | ( | const Message & | ) |
qpid::messaging::Message::~Message | ( | ) |
std::string qpid::messaging::Message::getContent | ( | ) | const |
Get the content as a std::string.
std::string qpid::messaging::Message::getContentBytes | ( | ) | const |
Get the content as raw bytes (an alias for getContent()
qpid::types::Variant& qpid::messaging::Message::getContentObject | ( | ) |
Get the content as a Variant, which can represent an object of different types.
This can be used for content representing a map or a list for example.
const qpid::types::Variant& qpid::messaging::Message::getContentObject | ( | ) | const |
Get the content as a Variant, which can represent an object of different types.
This can be used for content representing a map or a list for example.
const char* qpid::messaging::Message::getContentPtr | ( | ) | const |
Get a const pointer to the start of the content data.
The memory pointed to is owned by the message. The getContentSize() method indicates how much data there is (i.e. the extent of the memory region pointed to by the return value of this method).
size_t qpid::messaging::Message::getContentSize | ( | ) | const |
Get the size of content in bytes.
const std::string& qpid::messaging::Message::getContentType | ( | ) | const |
Returns the content type (i.e.
the MIME type) for the message. This can be used to determine how to decode the message content.
const std::string& qpid::messaging::Message::getCorrelationId | ( | ) | const |
bool qpid::messaging::Message::getDurable | ( | ) | const |
const std::string& qpid::messaging::Message::getMessageId | ( | ) | const |
uint8_t qpid::messaging::Message::getPriority | ( | ) | const |
const qpid::types::Variant::Map& qpid::messaging::Message::getProperties | ( | ) | const |
In addition to a payload (i.e.
the content), messages can include annotations describing aspectf of the message. In addition to the standard annotations such as TTL and content type, application- or context- specific properties can also be defined. Each message has a map of name values for such custom properties. The value is specified as a Variant.
qpid::types::Variant::Map& qpid::messaging::Message::getProperties | ( | ) |
bool qpid::messaging::Message::getRedelivered | ( | ) | const |
The redelivered flag if set implies that the message may have been previously delivered and thus is a hint to the application or messaging infrastructure that if de-duplication is required this message should be examined to determine if it is a duplicate.
const Address& qpid::messaging::Message::getReplyTo | ( | ) | const |
const std::string& qpid::messaging::Message::getSubject | ( | ) | const |
Duration qpid::messaging::Message::getTtl | ( | ) | const |
Get the time to live for this message in milliseconds.
const std::string& qpid::messaging::Message::getUserId | ( | ) | const |
void qpid::messaging::Message::setContent | ( | const std::string & | ) |
Set the content to the data held in the string parameter.
Note: this is treated as raw bytes and need not be text. Consider setting the content-type to indicate how the data should be interpreted by recipients.
void qpid::messaging::Message::setContent | ( | const char * | chars, |
size_t | count | ||
) |
Copy count bytes from the region pointed to by chars as the message content.
void qpid::messaging::Message::setContentBytes | ( | const std::string & | ) |
Set the content as raw bytes (an alias for setContent()
void qpid::messaging::Message::setContentObject | ( | const qpid::types::Variant & | ) |
Set the content using a Variant, which can represent an object of different types.
void qpid::messaging::Message::setContentType | ( | const std::string & | ) |
Set the content type (i.e.
the MIME type) for the message. This should be set by the sending application and indicates to recipients of message how to interpret or decode the content.
void qpid::messaging::Message::setCorrelationId | ( | const std::string & | ) |
Can be used to set application specific correlation identifiers as part of a protocol for message exchange patterns.
E.g. a request-reponse pattern might require the correlation-id of the request and response to match, or might use the message-id of the request as the correlation-id on the response etc.
void qpid::messaging::Message::setDurable | ( | bool | durable | ) |
Mark the message as durable.
This is a hint to the messaging infrastructure that the message should be persisted or otherwise stored such that failoures or shutdown do not cause it to be lost.
void qpid::messaging::Message::setMessageId | ( | const std::string & | ) |
Set an application defined identifier for the message.
At present this must be a stringfied UUID (support for less restrictive IDs is anticipated however).
void qpid::messaging::Message::setPriority | ( | uint8_t | ) |
Sets a priority level on the message.
This may be used by the messaging infrastructure to prioritise delivery of higher priority messages.
void qpid::messaging::Message::setProperties | ( | const qpid::types::Variant::Map & | ) |
void qpid::messaging::Message::setProperty | ( | const std::string & | , |
const qpid::types::Variant & | |||
) |
void qpid::messaging::Message::setRedelivered | ( | bool | ) |
Can be used to provide a hint to the application or messaging infrastructure that if de-duplication is required this message should be examined to determine if it is a duplicate.
void qpid::messaging::Message::setReplyTo | ( | const Address & | ) |
void qpid::messaging::Message::setSubject | ( | const std::string & | ) |
void qpid::messaging::Message::setTtl | ( | Duration | ttl | ) |
Set the time to live for this message in milliseconds.
This can be used by the messaging infrastructure to discard messages that are no longer of relevance.
void qpid::messaging::Message::setUserId | ( | const std::string & | ) |
Sets the user id of the message.
This should in general be the user-id as which the sending connection authenticated itself as the messaging infrastructure will verify this. See Connection::getAuthenticatedUsername()