mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(sns): preserve per-entry MessageAttributes in PublishBatch (#891)
The Query-protocol handler for sns:PublishBatch was extracting Id, Message, Subject, MessageGroupId and MessageDeduplicationId per entry but skipped the per-entry MessageAttributes parsing loop that the single-entry sns:Publish handler already had. As a result every batched message reached subscribers (SQS, HTTP, Lambda) with an empty attribute map, even though the AWS API contract treats MessageAttributes as a first-class field on PublishBatchRequestEntry. This caused consumers that rely on attributes for metadata (e.g. CloudEvents binary content-mode: ce-type, ce-id, ce-source, …) to discard the messages because the routing headers were missing. Mirror the loop from handlePublish, parsing PublishBatchRequestEntries.member.N.MessageAttributes.entry.M.* per entry, and only attach the attributes map when non-empty so the SnsService receives the same shape as the single-Publish path. Adds: - Handler unit regression test covering attribute forwarding and per-entry isolation (entry without attrs must not inherit from sibling entries). - AWS SDK v2 compatibility test asserting end-to-end fan-out. Existing single Publish behaviour is unchanged.
This commit is contained in:
1 parent
a51e434386
commit
e54a8e502c
3 files changed
+250
-5
No files matched your search
@@ -207,14 +207,26 @@ public class SnsQueryHandler {
|
||||
String topicArn = getParam(params, "TopicArn");
|
||||
List<Map<String, Object>> entries = new ArrayList<>();
|
||||
for (int i = 1; ; i++) {
|
||||
String id = getParam(params, "PublishBatchRequestEntries.member." + i + ".Id");
|
||||
String entryPrefix = "PublishBatchRequestEntries.member." + i;
|
||||
String id = getParam(params, entryPrefix + ".Id");
|
||||
if (id == null) break;
|
||||
Map<String, Object> entry = new java.util.HashMap<>();
|
||||
entry.put("Id", id);
|
||||
entry.put("Message", getParam(params, "PublishBatchRequestEntries.member." + i + ".Message"));
|
||||
entry.put("Subject", getParam(params, "PublishBatchRequestEntries.member." + i + ".Subject"));
|
||||
entry.put("MessageGroupId", getParam(params, "PublishBatchRequestEntries.member." + i + ".MessageGroupId"));
|
||||
entry.put("MessageDeduplicationId", getParam(params, "PublishBatchRequestEntries.member." + i + ".MessageDeduplicationId"));
|
||||
entry.put("Message", getParam(params, entryPrefix + ".Message"));
|
||||
entry.put("Subject", getParam(params, entryPrefix + ".Subject"));
|
||||
entry.put("MessageGroupId", getParam(params, entryPrefix + ".MessageGroupId"));
|
||||
entry.put("MessageDeduplicationId", getParam(params, entryPrefix + ".MessageDeduplicationId"));
|
||||
|
||||
Map<String, MessageAttributeValue> attributes = new HashMap<>();
|
||||
for (int j = 1; ; j++) {
|
||||
String attrPrefix = entryPrefix + ".MessageAttributes.entry." + j;
|
||||
String name = params.getFirst(attrPrefix + ".Name");
|
||||
if (name == null) break;
|
||||
String value = params.getFirst(attrPrefix + ".Value.StringValue");
|
||||
String dataType = params.getFirst(attrPrefix + ".Value.DataType");
|
||||
if (value != null) attributes.put(name, new MessageAttributeValue(value, dataType != null ? dataType : "String"));
|
||||
}
|
||||
if (!attributes.isEmpty()) entry.put("MessageAttributes", attributes);
|
||||
entries.add(entry);
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user