Closed
Description
Setting the message body and attributes on a SendMessageRequest
works as expected for me. When I try to send a SendMessageBatchRequest
, setting the message body and string attributes on each message, the message body makes it through as expected but no attributes do. I've tried doing this two different ways (there are a few lines of code specific to my repo mixed in here but I think this should be pretty legible... if you can't recreate this and want a self-contained application, I can put one together):
void SQSClient::sendMessageBatch(
const std::vector<std::string>& messageBody,
const std::vector<std::map<std::string, std::string>>& attributes)
{
if (messageBody.size() != attributes.size())
{
throw except::Exception(Ctxt("Sizes don't match"));
}
SendMessageBatchRequest request;
std::vector<SendMessageBatchRequestEntry> entries(messageBody.size());
for (size_t ii = 0; ii < messageBody.size(); ++ii)
{
SendMessageBatchRequestEntry entry;
entry.SetMessageBody(messageBody[ii].c_str());
const std::string id("some-batch-id-" + str::toString(ii));
entry.SetId(id.c_str());
// Try #1
Aws::Map<Aws::String, MessageAttributeValue> attMap;
for (auto iter : attributes[ii])
{
MessageAttributeValue stringAttributeValue;
stringAttributeValue.SetStringValue(iter.second.c_str());
stringAttributeValue.SetDataType("String");
attMap[iter.first.c_str()] = stringAttributeValue;
}
entry.SetMessageAttributes(attMap);
// Try #2
for (auto iter : attributes[ii])
{
MessageAttributeValue stringAttributeValue;
stringAttributeValue.SetStringValue(iter.second.c_str());
stringAttributeValue.SetDataType("String");
entry.AddMessageAttributes(iter.first.c_str(), stringAttributeValue);
}
request.AddEntries(entry);
}
request.SetQueueUrl(mQueueUrl);
// This succeeds, and the message bodies make it through, but no attributes do
SendMessageBatchOutcome outcome = mSqsClient->SendMessageBatch(request);
}
If I'm just doing something dumb, please let me know. :o)
Metadata
Metadata
Assignees
Labels
No labels