Skip to content

feat(rabbit): add connection event callbacks - #3266

Merged
IvanKirpichnikov merged 2 commits into
ag2ai:mainfrom
C3EQUALZz:feat/rabbit-broker-events
Oct 11, 2026
Merged

IvanKirpichnikov merged 2 commits into
ag2ai:mainfrom
C3EQUALZz:feat/rabbit-broker-events

Conversation

@C3EQUALZz

Copy link
Copy Markdown
Contributor

Description

RabbitBroker now accepts optional sequences of on_close and on_reconnected callbacks, allowing applications to observe connection loss and recovery without registering handlers on the aio-pika connection manually. Both arguments default to None and accept lists or tuples of sync and async functions. Each callback is registered on every new connection, so applications can keep logging, metrics, and other actions in separate handlers.

This PR also adds a RabbitMQ Broker Events guide with a runnable example, callback signatures, and links to the official aio-pika documentation. The guide explains that callback execution order is not guaranteed. Tests cover multiple handlers, connection closure during shutdown, broker restart, and automatic reconnection.

Related to #1545 (Broker event handlers).

Type of change

  • Documentation (typos, code examples, or any documentation updates)
  • New feature (a non-breaking change that adds functionality)
  • This change requires a documentation update

Checklist

  • My code adheres to the style guidelines of this project (just lint shows no errors)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • My changes do not generate any new warnings
  • I have added tests to validate the functionality of my new feature
  • Both new and existing tests pass locally with coverage
  • I have ensured that static analysis checks are passing
  • I have included code examples to illustrate the modifications

@IvanKirpichnikov
IvanKirpichnikov added this pull request to the merge queue Oct 11, 2026
Merged via the queue into ag2ai:main with commit 6e4e8ef Oct 11, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants