Adding MessageGroupId and MessageDeduplicationId (#3163)
Adding MessageGroupId and MessageDeduplicationId when sent from batch (#3101)
This commit is contained in:
parent
b09c8034e6
commit
bf8eb11dc3
@ -685,6 +685,8 @@ class SQSBackend(BaseBackend):
|
|||||||
entry["MessageBody"],
|
entry["MessageBody"],
|
||||||
message_attributes=entry["MessageAttributes"],
|
message_attributes=entry["MessageAttributes"],
|
||||||
delay_seconds=entry["DelaySeconds"],
|
delay_seconds=entry["DelaySeconds"],
|
||||||
|
group_id=entry.get("MessageGroupId"),
|
||||||
|
deduplication_id=entry.get("MessageDeduplicationId"),
|
||||||
)
|
)
|
||||||
message.user_id = entry["Id"]
|
message.user_id = entry["Id"]
|
||||||
|
|
||||||
|
@ -291,6 +291,16 @@ class SQSResponse(BaseResponse):
|
|||||||
[None],
|
[None],
|
||||||
)[0],
|
)[0],
|
||||||
"MessageAttributes": message_attributes,
|
"MessageAttributes": message_attributes,
|
||||||
|
"MessageGroupId": self.querystring.get(
|
||||||
|
"SendMessageBatchRequestEntry.{}.MessageGroupId".format(index),
|
||||||
|
[None],
|
||||||
|
)[0],
|
||||||
|
"MessageDeduplicationId": self.querystring.get(
|
||||||
|
"SendMessageBatchRequestEntry.{}.MessageDeduplicationId".format(
|
||||||
|
index
|
||||||
|
),
|
||||||
|
[None],
|
||||||
|
)[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
if entries == {}:
|
if entries == {}:
|
||||||
|
@ -1044,6 +1044,8 @@ def test_send_message_batch():
|
|||||||
"DataType": "String",
|
"DataType": "String",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"MessageGroupId": "message_group_id_1",
|
||||||
|
"MessageDeduplicationId": "message_deduplication_id_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": "id_2",
|
"Id": "id_2",
|
||||||
@ -1052,6 +1054,8 @@ def test_send_message_batch():
|
|||||||
"MessageAttributes": {
|
"MessageAttributes": {
|
||||||
"attribute_name_2": {"StringValue": "123", "DataType": "Number"}
|
"attribute_name_2": {"StringValue": "123", "DataType": "Number"}
|
||||||
},
|
},
|
||||||
|
"MessageGroupId": "message_group_id_2",
|
||||||
|
"MessageDeduplicationId": "message_deduplication_id_2",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -1066,10 +1070,22 @@ def test_send_message_batch():
|
|||||||
response["Messages"][0]["MessageAttributes"].should.equal(
|
response["Messages"][0]["MessageAttributes"].should.equal(
|
||||||
{"attribute_name_1": {"StringValue": "attribute_value_1", "DataType": "String"}}
|
{"attribute_name_1": {"StringValue": "attribute_value_1", "DataType": "String"}}
|
||||||
)
|
)
|
||||||
|
response["Messages"][0]["Attributes"]["MessageGroupId"].should.equal(
|
||||||
|
"message_group_id_1"
|
||||||
|
)
|
||||||
|
response["Messages"][0]["Attributes"]["MessageDeduplicationId"].should.equal(
|
||||||
|
"message_deduplication_id_1"
|
||||||
|
)
|
||||||
response["Messages"][1]["Body"].should.equal("body_2")
|
response["Messages"][1]["Body"].should.equal("body_2")
|
||||||
response["Messages"][1]["MessageAttributes"].should.equal(
|
response["Messages"][1]["MessageAttributes"].should.equal(
|
||||||
{"attribute_name_2": {"StringValue": "123", "DataType": "Number"}}
|
{"attribute_name_2": {"StringValue": "123", "DataType": "Number"}}
|
||||||
)
|
)
|
||||||
|
response["Messages"][1]["Attributes"]["MessageGroupId"].should.equal(
|
||||||
|
"message_group_id_2"
|
||||||
|
)
|
||||||
|
response["Messages"][1]["Attributes"]["MessageDeduplicationId"].should.equal(
|
||||||
|
"message_deduplication_id_2"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
|
Loading…
Reference in New Issue
Block a user