Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message footer and delivery annotation encoded into the outgoing payload #368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/message_sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ static SEND_ONE_MESSAGE_RESULT send_one_message(MESSAGE_SENDER_INSTANCE* message
AMQP_VALUE body_amqp_value = NULL;
size_t body_data_count = 0;
AMQP_VALUE msg_annotations = NULL;
AMQP_VALUE footer = NULL;
AMQP_VALUE delivery_annotations = NULL;
bool is_error = false;

// message header
Expand Down Expand Up @@ -302,6 +304,38 @@ static SEND_ONE_MESSAGE_RESULT send_one_message(MESSAGE_SENDER_INSTANCE* message
}
}

// footer
if ((!is_error) &&
(message_get_footer(message, &footer) == 0) &&
(footer != NULL))
{
if (amqpvalue_get_encoded_size(footer, &encoded_size) != 0)
{
LogError("Cannot obtain footer encoded size");
is_error = true;
}
else
{
total_encoded_size += encoded_size;
}
}

// delivery annotations
if ((!is_error) &&
(message_get_delivery_annotations(message, &delivery_annotations) == 0) &&
(delivery_annotations != NULL))
{
if (amqpvalue_get_encoded_size(delivery_annotations, &encoded_size) != 0)
{
LogError("Cannot obtain delivery annotations encoded size");
is_error = true;
}
else
{
total_encoded_size += encoded_size;
}
}

if (is_error)
{
result = SEND_ONE_MESSAGE_ERROR;
Expand Down Expand Up @@ -463,6 +497,28 @@ static SEND_ONE_MESSAGE_RESULT send_one_message(MESSAGE_SENDER_INSTANCE* message
log_message_chunk(message_sender, "Application properties:", application_properties_value);
}

if ((result == SEND_ONE_MESSAGE_OK) && (footer != NULL))
{
if (amqpvalue_encode(footer, encode_bytes, &payload) != 0)
{
LogError("Cannot encode footer value");
result = SEND_ONE_MESSAGE_ERROR;
}

log_message_chunk(message_sender, "Footer:", footer);
}

if ((result == SEND_ONE_MESSAGE_OK) && (delivery_annotations != NULL))
{
if (amqpvalue_encode(delivery_annotations, encode_bytes, &payload) != 0)
{
LogError("Cannot encode delivery annotations value");
result = SEND_ONE_MESSAGE_ERROR;
}

log_message_chunk(message_sender, "Delivery annotations:", delivery_annotations);
}

if (result == SEND_ONE_MESSAGE_OK)
{
switch (message_body_type)
Expand Down Expand Up @@ -595,6 +651,16 @@ static SEND_ONE_MESSAGE_RESULT send_one_message(MESSAGE_SENDER_INSTANCE* message
{
properties_destroy(properties);
}

if (footer != NULL)
{
annotations_destroy(footer);
}

if (delivery_annotations != NULL)
{
annotations_destroy(delivery_annotations);
}
}

return result;
Expand Down