Skip to content

Commit 210ded1

Browse files
authored
feat(event_sources): support for custom properties in ActiveMQEvent (aws-powertools#1999)
1 parent d81b940 commit 210ded1

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

aws_lambda_powertools/utilities/data_classes/active_mq_event.py

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def broker_out_time(self) -> int:
5555
"""Time stamp (in milliseconds) for when the message left the broker."""
5656
return self["brokerOutTime"]
5757

58+
@property
59+
def properties(self) -> dict:
60+
"""Custom properties"""
61+
return self["properties"]
62+
5863
@property
5964
def destination_physicalname(self) -> str:
6065
return self["destination"]["physicalname"]

tests/events/activeMQEvent.json

+13-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
},
1414
"timestamp": 1598827811958,
1515
"brokerInTime": 1598827811958,
16-
"brokerOutTime": 1598827811959
16+
"brokerOutTime": 1598827811959,
17+
"properties": {
18+
"testKey": "testValue"
19+
}
1720
},
1821
{
1922
"messageID": "ID:b-9bcfa592-423a-4942-879d-eb284b418fc8-1.mq.us-west-2.amazonaws.com-37557-1234520418293-4:1:1:1:1",
@@ -26,7 +29,11 @@
2629
},
2730
"timestamp": 1598827811958,
2831
"brokerInTime": 1598827811958,
29-
"brokerOutTime": 1598827811959
32+
"brokerOutTime": 1598827811959,
33+
"properties": {
34+
"testKey": "testValue"
35+
}
36+
3037
},
3138
{
3239
"messageID": "ID:b-9bcfa592-423a-4942-879d-eb284b418fc8-1.mq.us-west-2.amazonaws.com-37557-1234520418293-4:1:1:1:1",
@@ -39,7 +46,10 @@
3946
},
4047
"timestamp": 1598827811958,
4148
"brokerInTime": 1598827811958,
42-
"brokerOutTime": 1598827811959
49+
"brokerOutTime": 1598827811959,
50+
"properties": {
51+
"testKey": "testValue"
52+
}
4353
}
4454
]
4555
}

tests/functional/data_classes/test_amazon_mq.py

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_active_mq_event():
3030
assert message.timestamp is not None
3131
assert message.broker_in_time is not None
3232
assert message.broker_out_time is not None
33+
assert message.properties["testKey"] == "testValue"
3334
assert message.destination_physicalname is not None
3435
assert message.delivery_mode is None
3536
assert message.correlation_id is None

0 commit comments

Comments
 (0)