• Stars
    star
    120
  • Rank 295,924 (Top 6 %)
  • Language
    Erlang
  • Created about 14 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RabbitMQ Webhooks Plugin

RabbitMQ Webhooks Plugin

This plugin provides a "webhook" functionality to a RabbitMQ broker. Any message processed by this plugin will be forwarded to the URL you configure, using the method you give it.

Tested against RabbitMQ versions up to 2.8.1.

Changes

  • 0.15 - Re-built the .tar.gz file to makes sure it included the latest version of plugin code
  • 0.14 - Lots better error handling and a Ruby script for generating config files
  • 0.13 - Updated for use with the new plugin system in RabbitMQ 2.7
  • 0.12 - Updated for use with RabbitMQ 2.3.0, now uses rebar for build
  • 0.11 - Updated for use with RabbitMQ 2.2.0
  • 0.9 - Incorporated patch from @cameronharris for OTP R13 compatibility, Makefile tweak
  • 0.8 - Added error handling for request so bad URLs don't crash broker, fix for no message headers
  • 0.7 - Added send window functionality for sending webhook requests only during specified time windows
  • 0.6 - Added max_send config param for limiting how many outgoing HTTP requests happen
  • 0.5 - Use RabbitMQ's worker_pool for sending requests to handle massive dumps of messages
  • 0.4 - Accept more than just 200 status code for CouchDB
  • 0.3 - Asynchronous HTTP send, URL and method overrideable per-message.
  • 0.2 - URLs can be patterns and headers that start with "X-" get passed to REST URL.
  • 0.1 - Synchronous HTTP send, no URL patterns. Rough draft.

Install from Zip

Download the .tar.gz file from from the downloads section:

http://github.com/jbrisbin/rabbitmq-webhooks/downloads

	cd $RABBITMQ_HOME
	mkdir plugins
	cd plugins
	tar -zxvf ~/rabbit_webhooks-0.x.tar.gz

You should now have two .ez files in your plugins directory:

	lhttpc.ez
	rabbit_webhooks.ez

In 2.7, you'll have to enable the plugins to get them to work:

	rabbitmq-plugins enable rabbit_webhooks

To configure your broker, download the gen_config script from the source tree and run it, pointing to a YAML file that contains your configuration (discussed below).

Copy the output of that generation to your RabbitMQ server config file (should be some place like: /etc/rabbitmq/rabbitmq.config).

Start your broker and you should see output similar to what's discussed in the "Installing" section.

Install from Source

The build process for the webhooks plugin has changed. It now uses rebar to build.

	git clone https://github.com/jbrisbin/rabbitmq-webhooks.git
	cd rabbitmq-webhooks
	make
	make package

You can now install the three .ez files required:

	cp deps/amqp_client.ez $RABBITMQ_HOME/plugins
	cp deps/lhttpc.ez $RABBITMQ_HOME/plugins
	cp dist/rabbit_webhooks.ez $RABBITMQ_HOME/plugins

When you start the broker, you should see (at the top):

	... plugins activated:
	* lhttpc-1.2.5
	* rabbit_webhooks-0.14

and when the server is started:

	Configuring Webhooks...done

Logging is done to the server log file.

What can I use this for?

If you configure a webhook to bind to exchange "test" with routing key "#", any messages published with that exchange and routing key will be automatically sent to an HTTP URL based on pre-configured parameters, or by specifying overrides in the message properties and headers.

This would allow you, for example, to drop JSON data into messages in an AMQP queue which get sent to a REST URL via POST (or PUT or DELETE, etc...).

Clients with no access to a CouchDB server could send batches of updates through RabbitMQ. The webhooks plugin then HTTP POSTs those messages to the CouchDB server.

If the message is successfully POST/PUT/DELETE'd to the URL, it is ACK'd from the queue. If there was an error, the message is NOT ACK'd and stays in the queue for possible later delivery. There's probably a better way to handle this. I'm open for suggestions! :)

Example Configuration

As of v0.14, there is a Ruby script (scripts/gen_config) you can use to translate a YAML config file into the more complex and finicky Erlang config file. It will generate the correct atoms for you to include in your system rabbitmq.config file.

An example YAML file will look like this (with the bare minimum left uncommented, everything commented out is optional and the values shown are the defaults):

	--- # Test YAML file for driving config file generation.

	# Broker configuration
	username          : guest
	virtual_host      : /

	# Use a YAML alias to reference this one exchange for all configs.
	exchange: &webhook_exchange
	  name            : webhooks
	  # type            : topic
	  # auto_delete     : true
	  # durable         : false

	# Webhooks configurations
	webhooks:
	  - 
	    name            : webhook1 # Name should be unique within the config file
	    url             : http://localhost:8000/rest
	    # method          : post # get | post | put | delete
	    exchange        : *webhook_exchange
	    queue:
	      name          : webhook1 # Best to have the queue name match the config name
	    #   auto_delete   : true
	    # routing_key     : "#"
	    # max_send:
	    #   frequency     : 5
	    #   per           : second # second | minute | hour | day | week
	    # send_if:
	    #   between: 
	    #     start_hour  : 8 # 24-hour time
	    #     start_min   : 0
	    #     end_hour    : 17  # 24-hour time
	    #     end_min     : 0

If you want to configure it manually, an example Erlang config file is included in priv/:

	[
		{rabbit_webhooks, [
	    {username, <<"guest">>},
	    {virtual_host, <<"/">>},
			{webhooks, [
				{test_one, [
					{url, "http://localhost:8000/rest"},
					{method, post},
					{exchange, [
						{exchange, &lt;&lt;"webhooks.test"&gt;&gt;},
						{type, &lt;&lt;"topic"&gt;&gt;},
						{auto_delete, true},
						{durable, false}
					]},
					{queue, [
						{queue, &lt;&lt;"webhooks.test.q"&gt;&gt;},
						{auto_delete, true}
					]},
					{routing_key, &lt;&lt;"#"&gt;&gt;},
					{max_send, {5, second}},
					{send_if, [{between, {13, 24}, {13, 25}}]}
				]}
			]}
		]}
	].

TODO

Lots and lots still to do:

  • Make message sending more robust, including SSL support, authentication, and several other "would be nice to have"s.
  • Expose various statii to the RabbitMQ console.

License

Licensed under the Mozilla Public License:

http://www.rabbitmq.com/mpl.html

More Repositories

1

amqp_client

Rebar-friendly fork of rabbitmq-erlang-client
Erlang
101
star
2

riak-exchange

Custom RabbitMQ exchange type for sticking messages in Riak
Erlang
92
star
3

vcloud

Utilities for working in virtual cloud environments.
Java
58
star
4

akka-http-docker

Docker client based on Akka HTTP
Scala
48
star
5

riak-rabbitmq-commit-hooks

Riak RabbitMQ commit hooks
Erlang
48
star
6

rabbitmq-dsl

RabbitMQ Groovy DSL
Java
43
star
7

random-exchange

RabbitMQ exchange type for randomly selecting which queue to route to for load balancing.
Erlang
42
star
8

lager_amqp_backend

AMQP RabbitMQ Lager backend
Erlang
33
star
9

rabbit_common

Rebar-friendly fork of RabbitMQ common code
Erlang
32
star
10

misultin-riak-core-vnode-dispatcher

Misultin Riak Core VNode Dispatcher
Erlang
23
star
11

node-rlog

Node.js remote logging to Riak
JavaScript
22
star
12

disruptor

LMAX Disruptor port using Gradle
Java
20
star
13

asciibuild

Asciidoctor Extensions for literate programming
CSS
19
star
14

reactor-ntp-clock

java.time.Clock implementation that uses NTP and a Reactor Flux to manage the current time
Java
18
star
15

jstatebox

Statebox implementation for the JVM
Java
13
star
16

rabbit_riak_queue

Riak-backed RabbitMQ persistent queue implementation
Erlang
10
star
17

riak-session-manager

Tomcat Session Manager backed by Riak
Groovy
9
star
18

docker.mk

Makefile helper to compose Docker files from overlays
Go
9
star
19

rabbitmq-riak_core-vnode-dispatcher

RabbitMQ Riak Core VNode Dispatcher
Erlang
8
star
20

sockjs-riak_core-vnode-dispatcher

riak_core vnode Dispatcher that uses sockjs-erlang and cowboy
Erlang
8
star
21

log4j-async-file-appender

Log4J Appender using JDK 7's AsynchronousFileChannel
Java
6
star
22

node-vs-java-shootout

Node.js vs JVM (Java, Groovy, Grizzly) Shootout
JavaScript
6
star
23

grails-zookeeper-plugin

Grails ZooKeeper Helper Plugin
Java
6
star
24

confess-spring-data-rest

CONFESS 2013 Spring Data REST example
Java
5
star
25

oredev-demo

ร˜redev Demo Project
Java
5
star
26

riaktor

Riak data access using Reactor components
Java
5
star
27

rest-builder

Groovy DSL for doing HTTP testing
Shell
5
star
28

riak-async-java-client

Asynchronous, NIO-based Protocol Buffers client for Riak
Java
4
star
29

exslackbot

Slack Bot helper library for implementing bots in Elixir
Elixir
4
star
30

s12gx2012-rest

Spring Data REST SpringOne demo app
Java
4
star
31

riak_core_v8

Embed V8 Javascript into a riak_core vnode
JavaScript
4
star
32

cloud-utils-deployer

Ruby Gem of various utilities meant to aid the developer working with cloud architectures
Ruby
4
star
33

netmachine

Lightweight non-blocking application framework for the JVM
Java
4
star
34

tfl-ingest

Example app demonstrating the ingestion of TfL data into Riak via Kafka using Spring Cloud Stream
Groovy
3
star
35

rabbitplugin

Rebar template for RabbitMQ plugin project
Erlang
3
star
36

grizzly-http-client

Grizzly-based async HTTP client
Java
3
star
37

spring-riak

Riak support from Groovy and/or Java
Groovy
3
star
38

groovy-map-reduce

Groovy Map/Reduce Framework with RabbitMQ
Java
3
star
39

rabbitmq-misultin

RabbitMQ misultin plugin
2
star
40

rpi-python3

Raspbian Jessie image with Python 3 installed. It also installs utilties to help working with I2C.
2
star
41

elixir-dnsq

Dynamic MQTT-based DNS server
Elixir
1
star
42

pgbench

pgbench Dockerfile and Kubernetes manifests
1
star
43

bashobot

Slackbots for performing operations
JavaScript
1
star