This is an automated email from the ASF dual-hosted git repository. astitcher pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
commit e1d147e221d8192a9c3aacadeeda74105de5ba7b Author: Andrew Stitcher <astitc...@apache.org> AuthorDate: Fri Apr 18 17:22:05 2025 -0400 PROTON-2890: [Python examples] Simple recv now deduplicates more accurately This does use an ever expanding set, so this is not suitable for production use! For production use maybe the ids in the deduplication cache could be removed after a certain number of new messages have been received. --- python/examples/simple_recv.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/examples/simple_recv.py b/python/examples/simple_recv.py index f55dfa2df..61bf1bbd1 100755 --- a/python/examples/simple_recv.py +++ b/python/examples/simple_recv.py @@ -29,16 +29,20 @@ class Recv(MessagingHandler): self.url = url self.expected = count self.received = 0 + self.dedup_ids = set() def on_start(self, event): event.container.create_receiver(self.url) def on_message(self, event): - if event.message.id and event.message.id < self.received: + message = event.message + if message.id in self.dedup_ids: # ignore duplicate message + print(f"duplicate message ignored {message.id}") return + self.dedup_ids.add(message.id) if self.expected == 0 or self.received < self.expected: - print(event.message.body) + print(f"{message}") self.received += 1 if self.received == self.expected: event.receiver.close() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org