Skip to content

[mod_amqp] Add XML handler via AMQP with RPC reply pattern#3022

Open
alexey-khabulyak wants to merge 1 commit into
signalwire:masterfrom
alexey-khabulyak:amqp_xml_handler
Open

[mod_amqp] Add XML handler via AMQP with RPC reply pattern#3022
alexey-khabulyak wants to merge 1 commit into
signalwire:masterfrom
alexey-khabulyak:amqp_xml_handler

Conversation

@alexey-khabulyak
Copy link
Copy Markdown
Contributor

Description

Adds an XML handler for mod_amqp that allows FreeSWITCH to fetch XML configuration (directory, dialplan, etc.) from a remote backend over AMQP using the standard RPC reply_to/correlation_id pattern.

Architecture:

  • A dedicated reader thread establishes its own AMQP connection, declares a broker-assigned exclusive auto-delete queue (amq.gen-...), and consumes replies
  • A dedicated sender thread maintains a separate AMQP connection and publishes XML fetch requests to a configurable topic exchange, setting reply_to to the reader's queue name and a UUID as correlation_id
  • Each xml_amqp_fetch call creates a per-request APR queue (capacity 1), registers it in a hash by correlation_id, then blocks until the reader thread dispatches the response or the fetch timeout expires
  • The remote backend replies to the default exchange with routing_key = reply_to — no custom reply exchange needed

Removes mod_amqp_aux_connection_t entirely; the reader connection now reuses the existing mod_amqp_connection_t struct.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Code cleanup / refactor

Related Issues

Testing

  • Tested manually — verified end-to-end XML fetch using a Python test responder (test_xml_handler.py) against a live RabbitMQ 4.x broker; user_data FreeSWITCH command returns correct values from the remote XML response

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the project's style guidelines
  • I have added tests for my changes (if applicable)
  • All existing tests pass

Additional Notes

The fetch timeout (fetch_timeout_ms, default 5000ms) and circuit breaker (circuit_breaker_ms, default 10000ms) are configurable via amqp.conf.xml. See updated conf/vanilla/autoload_configs/amqp.conf.xml for reference configuration.

- Dedicated reader thread with broker-assigned exclusive queue
- Sender thread publishes requests with reply_to/correlation_id
- APR queue per request for response dispatch
- Configurable fetch timeout (fetch_timeout_ms, default 5000ms)
- Removes mod_amqp_aux_connection_t in favour of mod_amqp_connection_t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant