feat(pipes): populate SQS message attributes in pipe source records (#667)

This commit is contained in:
Christine Nguyen authored and GitHub committed 2026-04-30 18:15:56 -05:00
1 parent 21d85a8a8f
commit 30051b77c8
2 files changed
+123 -1

No files matched your search

@@ -12,6 +12,7 @@ import io.github.hectorvent.floci.services.pipes.model.DesiredState;
import io.github.hectorvent.floci.services.pipes.model.Pipe;
import io.github.hectorvent.floci.services.sqs.SqsService;
import io.github.hectorvent.floci.services.sqs.model.Message;
import io.github.hectorvent.floci.services.sqs.model.MessageAttributeValue;
import io.vertx.core.Vertx;
import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.ApplicationScoped;
@@ -19,6 +20,7 @@ import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -403,7 +405,18 @@ public class PipesPoller {
ObjectNode attrs = record.putObject("attributes");
attrs.put("ApproximateReceiveCount", String.valueOf(msg.getReceiveCount()));
attrs.put("SentTimestamp", String.valueOf(System.currentTimeMillis()));
record.putObject("messageAttributes");
ObjectNode msgAttrs = record.putObject("messageAttributes");
for (Map.Entry<String, MessageAttributeValue> entry : msg.getMessageAttributes().entrySet()) {
ObjectNode attrNode = msgAttrs.putObject(entry.getKey());
MessageAttributeValue val = entry.getValue();
attrNode.put("stringValue", val.getStringValue());
if (val.getBinaryValue() != null) {
attrNode.put("binaryValue", Base64.getEncoder().encodeToString(val.getBinaryValue()));
}
attrNode.putArray("stringListValues");
attrNode.putArray("binaryListValues");
attrNode.put("dataType", val.getDataType());
}
record.put("md5OfBody", msg.getMd5OfBody() != null ? msg.getMd5OfBody() : "");
record.put("eventSource", "aws:sqs");
record.put("eventSourceARN", pipe.getSource());