Skip to content

Commit c0af232

Browse files
committed
formatting
Signed-off-by: Gabriele Santomaggio <[email protected]>
1 parent 46d3a2e commit c0af232

File tree

2 files changed

+45
-74
lines changed

2 files changed

+45
-74
lines changed

examples/streams_with_filters/example_streams_with_filters.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ def __init__(self):
3030
def on_amqp_message(self, event: Event):
3131
# only messages with banana filters and with subject yellow
3232
self._count = self._count + 1
33-
logger.info("Received message: {}, subject {}.[Total Consumed: {}]".
34-
format(Converter.bytes_to_string(event.message.body), event.message.subject, self._count))
33+
logger.info(
34+
"Received message: {}, subject {}.[Total Consumed: {}]".format(
35+
Converter.bytes_to_string(event.message.body),
36+
event.message.subject,
37+
self._count,
38+
)
39+
)
3540
self.delivery_context.accept(event)
3641

3742
def on_connection_closed(self, event: Event):
@@ -82,15 +87,16 @@ def main() -> None:
8287
consumer = consumer_connection.consumer(
8388
addr_queue,
8489
message_handler=MyMessageHandler(),
85-
8690
# the consumer will only receive messages with filter value banana and subject yellow
87-
8891
stream_consumer_options=StreamConsumerOptions(
8992
offset_specification=OffsetSpecification.first,
9093
filter_options=StreamFilterOptions(
9194
values=["banana"],
92-
message_properties=MessageProperties(subject="yellow", )))
93-
95+
message_properties=MessageProperties(
96+
subject="yellow",
97+
),
98+
),
99+
),
94100
)
95101
print(
96102
"create a consumer and consume the test message - press control + c to terminate to consume"

rabbitmq_amqp_python_client/entities.py

Lines changed: 33 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -150,75 +150,40 @@ class ExchangeToExchangeBindingSpecification:
150150
binding_key: Optional[str] = None
151151

152152

153+
@dataclass
153154
class MessageProperties:
154-
def __init__(
155-
self,
156-
message_id: Optional[Any] = None,
157-
user_id: Optional[bytes] = None,
158-
to: Optional[str] = None,
159-
subject: Optional[str] = None,
160-
reply_to: Optional[str] = None,
161-
correlation_id: Optional[Any] = None,
162-
content_type: Optional[str] = None,
163-
content_encoding: Optional[str] = None,
164-
absolute_expiry_time: Optional[datetime] = None,
165-
creation_time: Optional[datetime] = None,
166-
group_id: Optional[str] = None,
167-
group_sequence: Optional[int] = None,
168-
reply_to_group_id: Optional[str] = None,
169-
):
170-
# Message-id, if set, uniquely identifies a message within the message system.
171-
# The message producer is usually responsible for setting the message-id in
172-
# such a way that it is assured to be globally unique. A broker MAY discard a
173-
# message as a duplicate if the value of the message-id matches that of a
174-
# previously received message sent to the same node.
175-
#
176-
# The value is restricted to the following types:
177-
# - int (for uint64), UUID, bytes, or str
178-
self.message_id: Optional[Any] = message_id
179-
180-
# The identity of the user responsible for producing the message.
181-
# The client sets this value, and it MAY be authenticated by intermediaries.
182-
self.user_id: Optional[bytes] = user_id
183-
184-
# The to field identifies the node that is the intended destination of the message.
185-
# On any given transfer this might not be the node at the receiving end of the link.
186-
self.to: Optional[str] = to
187-
188-
# A common field for summary information about the message content and purpose.
189-
self.subject: Optional[str] = subject
190-
191-
# The address of the node to send replies to.
192-
self.reply_to: Optional[str] = reply_to
193-
194-
# This is a client-specific id that can be used to mark or identify messages
195-
# between clients.
196-
#
197-
# The value is restricted to the following types:
198-
# - int (for uint64), UUID, bytes, or str
199-
self.correlation_id: Optional[Any] = correlation_id
200-
201-
# The RFC-2046 [RFC2046] MIME type for the message's application-data section (body).
202-
self.content_type: Optional[str] = content_type
203-
204-
# The content-encoding property is used as a modifier to the content-type.
205-
self.content_encoding: Optional[str] = content_encoding
206-
207-
# An absolute time when this message is considered to be expired.
208-
self.absolute_expiry_time: Optional[datetime] = absolute_expiry_time
209-
210-
# An absolute time when this message was created.
211-
self.creation_time: Optional[datetime] = creation_time
212-
213-
# Identifies the group the message belongs to.
214-
self.group_id: Optional[str] = group_id
215-
216-
# The relative position of this message within its group.
217-
self.group_sequence: Optional[int] = group_sequence
218-
219-
# This is a client-specific id that is used so that client can send replies to this
220-
# message to a specific group.
221-
self.reply_to_group_id: Optional[str] = reply_to_group_id
155+
"""
156+
Properties for an AMQP message.
157+
158+
Attributes:
159+
message_id: Uniquely identifies a message within the system (int, UUID, bytes, or str).
160+
user_id: Identity of the user responsible for producing the message.
161+
to: Intended destination node of the message.
162+
subject: Summary information about the message content and purpose.
163+
reply_to: Address of the node to send replies to.
164+
correlation_id: Client-specific id for marking or identifying messages (int, UUID, bytes, or str).
165+
content_type: RFC-2046 MIME type for the message's body.
166+
content_encoding: Modifier to the content-type.
167+
absolute_expiry_time: Absolute time when the message expires.
168+
creation_time: Absolute time when the message was created.
169+
group_id: Group the message belongs to.
170+
group_sequence: Relative position of this message within its group.
171+
reply_to_group_id: Id for sending replies to a specific group.
172+
"""
173+
174+
message_id: Optional[Any] = None
175+
user_id: Optional[bytes] = None
176+
to: Optional[str] = None
177+
subject: Optional[str] = None
178+
reply_to: Optional[str] = None
179+
correlation_id: Optional[Any] = None
180+
content_type: Optional[str] = None
181+
content_encoding: Optional[str] = None
182+
absolute_expiry_time: Optional[datetime] = None
183+
creation_time: Optional[datetime] = None
184+
group_id: Optional[str] = None
185+
group_sequence: Optional[int] = None
186+
reply_to_group_id: Optional[str] = None
222187

223188

224189
"""

0 commit comments

Comments
 (0)