Message versioning can be required in SNS+SQS patternto allow setting up specific consumers that can process newer versions and make version transitions smooth and painless.
To achieve that you can use the native AWS SNS filtering mechanism.
It allows to set version
message attribute on a message sent to SNS and filter which queues receive which versions
of messages.
{
"Type": "Notification",
"MessageId": "d5c1bc6c-efe8-5dc3-af32-e46edec1027f",
"TopicArn": "arn:aws:sns:eu-west-1:000000000000:test",
"Message": "some message",
"Timestamp": "2020-10-15T11:13:45.002Z",
"MessageAttributes": {
"version": {
"Type": "Number",
"Value": "1"
}
}
}
Subscription filter policy that allows only messages with specific versions:
{
"version": [1, 2]
}
Subscription filter policy that allows all version except a specific one:
{
"version": [{"anything-but": 3}]
}
Subscription filter policy that allows a range of versions:
{
"version": [{"numeric": [">", 2, "<=", 5]}]
}