-
Notifications
You must be signed in to change notification settings - Fork 166
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
SNS MessageAttributes propagation to SQS in case raw message delivery is disabled #225
Comments
I'm not fully sure what is going on here. |
Here is the example of SQS message that has Raw delivery enbled. As you can see MessageAttributes are present including tracing information in b3 attribute. In that case tracing propagation works just fine {
"Messages": [
{
"MessageId": "6d4beb30-2b87-4870-b8aa-f3d6dd07d74e",
"ReceiptHandle": "MGRlNjRjMGItNWIyZS00YjYxLWIyZTQtZmFlNzhmMGQ1ZmU1IGFybjphd3M6c3FzOmV1LXdlc3QtMTowMDAwMDAwMDAwMDA6c3FzLWNsaS1sb2NhbHN0YWNrLXJhcyA2ZDRiZWIzMC0yYjg3LTQ4NzAtYjhhYS1mM2Q2ZGQwN2Q3NGUgMTY4NTcxMDk3NS40MzU2NzE2",
"MD5OfBody": "a8e03a1f60fcce3753d49c993a0f5721",
"Body": "Hello message",
"Attributes": {
"SenderId": "000000000000",
"SentTimestamp": "1685710975434",
"ApproximateReceiveCount": "1",
"ApproximateFirstReceiveTimestamp": "1685710975435"
},
"MD5OfMessageAttributes": "c33345af991f90db9ab13ba4c800a7ae",
"MessageAttributes": {
"b3": {
"StringValue": "d5091d50d920828c-3e2c0ff1bcd41283-0",
"DataType": "String"
}
}
}
]
}
However this is how SQS message looks when Raw delivery is not enabled: {
"Messages": [
{
"MessageId": "4bcc90c7-5b7c-462d-bf47-da4ab0f3d32a",
"ReceiptHandle": "ZmY2Y2VjNTgtMDNlMi00NzQwLWIxM2QtNDU1ZDk1Y2I1NmMxIGFybjphd3M6c3FzOmV1LXdlc3QtMTowMDAwMDAwMDAwMDA6c3FzLWJmZi1sb2NhbHN0YWNrLXJhcyA0YmNjOTBjNy01YjdjLTQ2MmQtYmY0Ny1kYTRhYjBmM2QzMmEgMTY4NTcwMjQ2NS4wNjQ5ODc0",
"MD5OfBody": "c4cf7c76b3329ffbc93bf80f43cbe35a",
"Body": "{\"Type\": \"Notification\", \"MessageId\": \"950ffc8c-f390-4bd8-9203-2cf7ef3b1fec\", \"TopicArn\": \"arn:aws:sns:eu-west-1:000000000000:sns-bff-localstack-ras\", \"Message\": \"Hello message\", \"Timestamp\": \"2023-06-02T10:40:50.072Z\", \"SignatureVersion\": \"1\", \"Signature\": \"EXAMPLEpH+..\", \"SigningCertURL\": \"https://sns.us-east-1.amazonaws.com/SimpleNotificationService-0000000000000000000000.pem\", \"UnsubscribeURL\": \"http://localhost:4566/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:000000000000:sns-bff-localstack-ras:17c7a1c0-215b-4d5a-8669-dad566df4aa6\", \"MessageAttributes\": {\"b3\": {\"Type\": \"String\", \"Value\": \"072a7fbcd3e57527-837904d83ef49e81-0\"}, \"subject\": {\"Type\": \"String\", \"Value\": \"subject\"}, \"foo\": {\"Type\": \"String\", \"Value\": \"bar\"}, \"topic\": {\"Type\": \"String\", \"Value\": \"topic\"}}}",
"Attributes": {
"SenderId": "000000000000",
"SentTimestamp": "1685702450082",
"ApproximateReceiveCount": "1",
"ApproximateFirstReceiveTimestamp": "1685702465064"
}
}
]
}
MessageAttributes are wrapped inside Body and the tracing propagation doesn't work. I was thinking if I can register some custom header extractor and extract attributes from the Body it would solve the issue. |
Well, it is a bit different, than what is explained in the official AWS docs: https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html. So, if that a case and you indeed uses an If you can share with us more info that some indicator is present in the |
Hi @artembilan , thanks for your involment. |
OK. So, probably there is no any clues in the incoming SQS message to determine that it was raw or not. If there is any SQS attribute in the incoming message indicating that |
I don't think that there is such attribute indicating raw delivery. Maybe SqsMessageDrivenChannelAdapter could implement the appropriate logic depending setRawDelivery(boolean) |
Not sure what you mean. |
I'm aware of EIP but this topic concerns instrumentation at low level. And this is where I'm lost. It probably involves TracingChannelInterceptor but honestly I don't know what needs to be done to register custom code to extract b3 tracing data from the SQS message. |
Custom transformer to parse that |
When SQS subscription is set for SNS topic without raw message delivery option enabled then message attributes from original SNS message are wrapped in Body attribute.
This causes that tracing information is not found
Expected beahvior:
Message attributes should be mapped depending of raw message delivery option
The text was updated successfully, but these errors were encountered: