Skip to content

Commit 958d4ee

Browse files
authored
Add example with MessageEvent.with_auto_ack() (#14)
1 parent 3038588 commit 958d4ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ async with asyncio.TaskGroup() as task_group:
8888
async for event in client.listen():
8989
match event:
9090
case stompman.MessageEvent(body=body):
91-
task_group.create_task(handle_message(body))
91+
task_group.create_task(
92+
event.with_auto_ack(
93+
handle_message(body),
94+
on_suppressed_exception=lambda _exception, event: logger.exception(
95+
"Failed to process message", event=event
96+
),
97+
)
98+
)
9299
case stompman.ErrorEvent(message_header=short_description, body=body):
93100
logger.error(
94101
"Received an error from server", short_description=short_description, body=body, event=event

0 commit comments

Comments
 (0)