@@ -29,11 +29,13 @@ def __init__(self):
2929
3030 def on_amqp_message (self , event : Event ):
3131 # only messages with banana filters and with subject yellow
32+ # and application property from = italy get received
3233 self ._count = self ._count + 1
3334 logger .info (
34- "Received message: {}, subject {}.[Total Consumed: {}]" .format (
35+ "Received message: {}, subject {} application properties {} .[Total Consumed: {}]" .format (
3536 Converter .bytes_to_string (event .message .body ),
3637 event .message .subject ,
38+ event .message .application_properties ,
3739 self ._count ,
3840 )
3941 )
@@ -88,13 +90,15 @@ def main() -> None:
8890 addr_queue ,
8991 message_handler = MyMessageHandler (),
9092 # the consumer will only receive messages with filter value banana and subject yellow
93+ # and application property from = italy
9194 stream_consumer_options = StreamConsumerOptions (
9295 offset_specification = OffsetSpecification .first ,
9396 filter_options = StreamFilterOptions (
9497 values = ["banana" ],
9598 message_properties = MessageProperties (
9699 subject = "yellow" ,
97100 ),
101+ application_properties = {"from" : "italy" }
98102 ),
99103 ),
100104 )
@@ -108,11 +112,13 @@ def main() -> None:
108112 # publish with a filter of apple
109113 for i in range (MESSAGES_TO_PUBLISH ):
110114 color = "green" if i % 2 == 0 else "yellow"
115+ from_value = "italy" if i % 3 == 0 else "spain"
111116 publisher .publish (
112117 Message (
113118 Converter .string_to_bytes (body = "apple: " + str (i )),
114119 annotations = {"x-stream-filter-value" : "apple" },
115120 subject = color ,
121+ application_properties = {"from" : from_value },
116122 )
117123 )
118124
@@ -121,11 +127,13 @@ def main() -> None:
121127 # publish with a filter of banana
122128 for i in range (MESSAGES_TO_PUBLISH ):
123129 color = "green" if i % 2 == 0 else "yellow"
130+ from_value = "italy" if i % 3 == 0 else "spain"
124131 publisher .publish (
125132 Message (
126133 body = Converter .string_to_bytes ("banana: " + str (i )),
127134 annotations = {"x-stream-filter-value" : "banana" },
128135 subject = color ,
136+ application_properties = {"from" : from_value },
129137 )
130138 )
131139
0 commit comments