This plugin extends RabbitMQ by forwarding messages from one or more queues to
arbitrary HTTP endpoints (often called webhooks). It is inspired by the
unmaintained rabbitmq-webhooks plugin by Jon Brisbin and is designed to
work with modern RabbitMQ releases (3.10 and newer). The code provided here
forms the basis for a complete plugin; it can be built into an .ez file and
enabled on a running broker. The plugin connects to the broker using a
direct AMQP connection, consumes messages from configured queues and then
sends the message payload to the configured URL using the specified HTTP
method. Messages are acknowledged only if the HTTP request succeeds (HTTP
status 2xx–3xx), otherwise they are requeued for another attempt.
- Per‑queue webhooks: configure one or more queues to be forwarded to different URLs. Each webhook entry defines the queue name, the target URL and the HTTP method to use.
- Direct connection: the plugin uses
amqp_client's#amqp_params_direct{}type to connect to the same Erlang node that the broker is running on. No network sockets need to be opened and the plugin can authenticate using theguestuser or another account. - Synchronous HTTP calls: outgoing requests are sent using Erlang’s
built‑in
inetsHTTP client (httpc). Only when a request returns a successful response does the plugin acknowledge the message; otherwise the message is nacked and requeued. - Simple configuration: define webhook entries in either
rabbitmq.confformat or the legacyrabbitmq.configformat. Multiple webhooks can be defined under the same plugin.
-
Clone the plugin source into the RabbitMQ source tree or another directory under your build root. The plugin is structured like other RabbitMQ plugins (see the metronome example).
-
Build the plugin. RabbitMQ plugins are normally built with
erlang.mkand the RabbitMQ‑specificrabbitmq-components.mkandrabbitmq-plugins.mkfiles. An exampleMakefileis provided in this directory. If you already build RabbitMQ from source, copy or symlinkerlang.mk,rabbitmq-components.mkandrabbitmq-plugins.mkfrom the RabbitMQ source tree into this directory and run:make dist
The resulting
.ezarchive will be written to thedist/directory. -
Install the compiled plugin by copying the
.ezfile into the broker’splugins/directory and enabling it:cp dist/rabbit_callwebhooks.ez $RABBITMQ_HOME/plugins/ rabbitmq-plugins enable rabbit_callwebhooks
-
Configure the plugin (see below) and restart the broker.
The plugin reads its configuration from the application environment key
rabbit_callwebhooks under the webhooks entry. Each webhook entry must
include a queue name, a URL and a method. Optional fields such as
username, password and vhost can be provided when the queue lives in
a vhost other than / or must be accessed by a different user.
Using the modern rabbitmq.conf format:
rabbit_callwebhooks.webhooks.1.queue = my.queue
rabbit_callwebhooks.webhooks.1.url = https://example.com/webhook
rabbit_callwebhooks.webhooks.1.method = post
rabbit_callwebhooks.webhooks.2.queue = other.queue
rabbit_callwebhooks.webhooks.2.url = https://api.example.net/endpoint
rabbit_callwebhooks.webhooks.2.method = put
rabbit_callwebhooks.webhooks.2.username = webhook_user
rabbit_callwebhooks.webhooks.2.password = s3cret
rabbit_callwebhooks.webhooks.2.vhost = /myvhostWhen using the legacy rabbitmq.config format (Erlang terms):
{rabbit_callwebhooks, [
{webhooks, [
#{queue => <<"my.queue">>,
url => <<"https://example.com/webhook">>,
method => post},
#{queue => <<"other.queue">>,
url => <<"https://api.example.net/endpoint">>,
method => put,
username => <<"webhook_user">>,
password => <<"s3cret">>,
vhost => <<"/myvhost">>}
]}
]}.| Path | Purpose |
|---|---|
src/rabbit_callwebhooks.app.src |
Defines the OTP application for the plugin and its dependencies. |
src/rabbit_callwebhooks_app.erl |
Application behaviour implementation; starts the top‑level supervisor. |
src/rabbit_callwebhooks_sup.erl |
Supervisor that starts a worker process for each configured webhook. |
src/rabbit_callwebhooks_worker.erl |
Worker process that consumes messages from a queue and delivers them to an HTTP endpoint. |
Makefile |
Example build file for compiling the plugin using erlang.mk. |
- The HTTP client used is Erlang’s built‑in
httpcfrom theinetsapplication. For higher performance or advanced features (e.g. HTTPS client certificates), consider replacing it with another client such ashackney. - Errors during HTTP delivery will result in messages being nacked and requeued. There is no dead‑letter handling built in.
- There is no batching or rate limiting; each message triggers one HTTP call.
- The plugin currently forwards the raw payload as the request body and does not set any additional headers. You can extend
send_http/4inrabbit_callwebhooks_worker.erlto include message headers or properties.
This plugin is heavily inspired by the historical
rabbitmq-webhooks project【506323775653347†L260-L365】. Many thanks to Jon Brisbin for the original idea.