YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
|
Outgoing message. More...
#include <outgoing_message.h>
Public Types | |
typedef long long | outgoing_message_id |
Outgoing message identifier type. | |
Public Member Functions | |
outgoing_message () | |
Constructor. More... | |
void | reset (details::outgoing_message_manager &manager, details::outgoing_message_info &info) |
void | disown_info_object () |
message_state | get_state () const |
Returns the state of this message. | |
message_state | get_state (std::size_t &sent_bytes, std::size_t &total_byte_count) const |
Returns the state of this message. More... | |
void | wait_for_transmission () const |
Waits for the transmission to finish. More... | |
bool | wait_for_transmission (std::size_t relative_timeout) const |
Waits for the transmission to finish or until timeout expires. More... | |
void | wait_for_completion () const |
Waits for the full message roundtrip. More... | |
bool | wait_for_completion (std::size_t relative_timeout) const |
Waits for the message roundtrip or until timeout expires. More... | |
const parameters & | get_header () const |
Provides access to the reply header. | |
const parameters & | get_reply () const |
Provides access to the reply content. | |
const std::vector< char > & | get_raw_reply () const |
Provides access to the reply content. More... | |
parameters * | extract_reply () |
Extracts the reply content. More... | |
const std::string & | get_exception_msg () const |
Returns the exception message. More... | |
outgoing_message_id | get_message_id () const |
Returns the internal message id. More... | |
Outgoing message.
The handler allowing to track the progress of outgoing message, inspect its state and to obtain the reply content.
Note: The objects of this class can be safely used from multiple threads.
yami::outgoing_message::outgoing_message | ( | ) |
Constructor.
Creates uninitialized outgoing message object.
parameters * yami::outgoing_message::extract_reply | ( | ) |
Extracts the reply content.
The reply content is moved to the caller and the caller becomes the owner of the parameters
object. This object itself is no longer holding any references to the content and therefore any future attempts to access it will result in the exception.
const std::string & yami::outgoing_message::get_exception_msg | ( | ) | const |
Returns the exception message.
This function can be called when the state of message is "rejected".
outgoing_message_id yami::outgoing_message::get_message_id | ( | ) | const |
Returns the internal message id.
This function can be useful together with asynchronous callbacks, the message id is the one that was returned by agent::send.
const std::vector< char > & yami::outgoing_message::get_raw_reply | ( | ) | const |
Provides access to the reply content.
Note: this function can be used only when the data is delivered in the raw buffer form.
message_state yami::outgoing_message::get_state | ( | std::size_t & | sent_bytes, |
std::size_t & | total_byte_count | ||
) | const |
Returns the state of this message.
This function allows to inspect the progress of the message transmission. During transmission the sent_bytes
value is always smaller than total_byte_count
. When these two values become equal, it means that the transmission was either succesful or abandoned.
sent_bytes | The number of bytes that were already sent for this message. |
total_byte_count | The total number of bytes that should be sent for this message. |
void yami::outgoing_message::wait_for_completion | ( | ) | const |
Waits for the full message roundtrip.
Waits for the full message roundtrip - that is, for some confirmation that the message has been received and reacted upon by the target agent. After this function returns the state of the message is either abandoned
, replied
or rejected
.
Note: This function should not be called if the intended semantics of the message is "one-way" - in this case this function would block indefinitely.
bool yami::outgoing_message::wait_for_completion | ( | std::size_t | relative_timeout | ) | const |
Waits for the message roundtrip or until timeout expires.
Waits for the full message roundtrip or until the given relative timeout expires.
relative_timeout | The relative timeout in milliseconds. |
true
if the wait completed before the timeoutfalse
if the timeout expired before the message was completed void yami::outgoing_message::wait_for_transmission | ( | ) | const |
Waits for the transmission to finish.
Waits for the transmission to finish - that is, to either send all the message data or to abandon it. After this function returns the state of the message is either transmitted
, abandoned
, replied
or rejected
.
bool yami::outgoing_message::wait_for_transmission | ( | std::size_t | relative_timeout | ) | const |
Waits for the transmission to finish or until timeout expires.
Waits for the transmission to finish or until the given relative timeout expires.
relative_timeout | The relative timeout in milliseconds. |
true
if the wait completed before the timeoutfalse
if the timeout expired before the message was fully transmitted