Skip to content

feat(consumer): quorum SAC notifications via FLOW rabbitmq:active#109

Merged
Gsantomaggio merged 2 commits into
mainfrom
feat/qq_sac_notification
May 11, 2026
Merged

feat(consumer): quorum SAC notifications via FLOW rabbitmq:active#109
Gsantomaggio merged 2 commits into
mainfrom
feat/qq_sac_notification

Conversation

@Gsantomaggio
Copy link
Copy Markdown
Member

Register the SAC callback on the AMQP transport before receiver creation so the initial rabbitmq:active FLOW frame – sent by RabbitMQ 4.3+ as part of the ATTACH handshake – is captured correctly.

New files:

  • rabbitmq_amqp_python_client/qpid/proton/_flow_properties.py Low-level AMQP byte parser that scans raw frames for FLOW performatives and extracts the rabbitmq:active boolean from the link-state properties map.
  • tests/test_quorum_queue_sac.py Integration tests: first consumer becomes active, second starts as standby, standby promoted on active close, plus validation tests.
  • examples/quorum_queue_sac/example_quorum_queue_sac.py Runnable demo with two consumers showing live ACTIVE/STANDBY transitions.

Modified files:

  • qpid/proton/_handlers.py: hook IOHandler.on_selectable_readable to invoke the SAC callback whenever a matching FLOW frame arrives.
  • entities.py: add QuorumConsumerOptions(sac_state_handler=...) with validation (requires RabbitMQ 4.3+, incompatible with DirectReplyTo).
  • consumer.py: _register_sac_callback() / _unregister_sac_callback() stored on conn.transport; registration happens before _create_receiver() to avoid the timing race with the initial ATTACH FLOW frame.
  • connection.py: pass "4.3.0" version flag to consumer_options.validate().
  • init.py: export QuorumConsumerOptions in the public API.
  • CHANGELOG.md, examples/README.md: document the new feature.

Register the SAC callback on the AMQP transport *before* receiver
creation so the initial rabbitmq:active FLOW frame – sent by
RabbitMQ 4.3+ as part of the ATTACH handshake – is captured correctly.

New files:
- rabbitmq_amqp_python_client/qpid/proton/_flow_properties.py
  Low-level AMQP byte parser that scans raw frames for FLOW performatives
  and extracts the rabbitmq:active boolean from the link-state properties map.
- tests/test_quorum_queue_sac.py
  Integration tests: first consumer becomes active, second starts as
  standby, standby promoted on active close, plus validation tests.
- examples/quorum_queue_sac/example_quorum_queue_sac.py
  Runnable demo with two consumers showing live ACTIVE/STANDBY transitions.

Modified files:
- qpid/proton/_handlers.py: hook IOHandler.on_selectable_readable to
  invoke the SAC callback whenever a matching FLOW frame arrives.
- entities.py: add QuorumConsumerOptions(sac_state_handler=...) with
  validation (requires RabbitMQ 4.3+, incompatible with DirectReplyTo).
- consumer.py: _register_sac_callback() / _unregister_sac_callback()
  stored on conn.transport; registration happens before _create_receiver()
  to avoid the timing race with the initial ATTACH FLOW frame.
- connection.py: pass "4.3.0" version flag to consumer_options.validate().
- __init__.py: export QuorumConsumerOptions in the public API.
- CHANGELOG.md, examples/README.md: document the new feature.

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
@Gsantomaggio Gsantomaggio self-assigned this May 11, 2026
@Gsantomaggio Gsantomaggio added the enhancement New feature or request label May 11, 2026
@Gsantomaggio Gsantomaggio added this to the 0.7.0 milestone May 11, 2026
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant