Home > rabbitmq-http-safe

rabbitmq-http-safe

Rabbitmq-http-safe is a project mainly written in Erlang, based on the View license.

A store-and-forward HTTP gateway plugin for RabbitMQ.

      ___                                   ___                  ___           ___           ___         ___     
     /__/\          ___         ___        /  /\                /  /\         /  /\         /  /\       /  /\    
     \  \:\        /  /\       /  /\      /  /::\              /  /:/_       /  /::\       /  /:/_     /  /:/_   
      \__\:\      /  /:/      /  /:/     /  /:/\:\            /  /:/ /\     /  /:/\:\     /  /:/ /\   /  /:/ /\  
  ___ /  /::\    /  /:/      /  /:/     /  /:/~/:/           /  /:/ /::\   /  /:/~/::\   /  /:/ /:/  /  /:/ /:/_ 
 /__/\  /:/\:\  /  /::\     /  /::\    /__/:/ /:/           /__/:/ /:/\:\ /__/:/ /:/\:\ /__/:/ /:/  /__/:/ /:/ /\
 \  \:\/:/__\/ /__/:/\:\   /__/:/\:\   \  \:\/:/            \  \:\/:/~/:/ \  \:\/:/__\/ \  \:\/:/   \  \:\/:/ /:/
  \  \::/      \__\/  \:\  \__\/  \:\   \  \::/              \  \::/ /:/   \  \::/       \  \::/     \  \::/ /:/ 
   \  \:\           \  \:\      \  \:\   \  \:\               \__\/ /:/     \  \:\        \  \:\      \  \:\/:/  
    \  \:\           \__\/       \__\/    \  \:\                /__/:/       \  \:\        \  \:\      \  \::/   
     \__\/                                 \__\/                \__\/         \__\/         \__\/       \__\/    

RabbitMQ HTTP SAFE (Store And Forward Engine)

A store-and-forward HTTP gateway plugin for RabbitMQ.

Goal

To simplify the integration and communication of services over HTTP by relieving systems from the chore of resending requests when something went wrong with "the other side".

http-safe goes beyond the fire and forget paradigm as it supports the notion of delivery callback in order to inform the originating system of the success or failure of its dispatch request.

If you're running in the cloud and are OK using Amazon AWS, then consider using SNS instead of http-safe :)

Installation

In order to use the http-safe plugin, you need first to install the following plugins on RabbitMQ 2.3.1:

  • amqp_client
  • mochiweb
  • rabbitmq-mochiweb
  • ibrowse

If you don't build the plugin from source, then get the latest one from the above download link.

Configuration

Good news: there is nothing to configure in order to use http-safe.

If you're not happy with the port it's listening on, you'll need to configure the Mochiweb plugin as explained here.

Usage

Using http-safe is very straightforward: you simply send it the HTTP request your intending to send to a server, using whatever verb you want, and just add a few control headers. http-safe will then try to send it to the intended recipient as fast as it can, retrying as much and as often as configured. In case of success or failure, it can optionally call you back.

After sending to http://:55672/http-safe/in, http-safe responds:

204
X-SAFE-Correlation-Id: <correlation_id>

This correlation ID header will be added to the dispatched HTTP request for traceability.

Here are the HTTP headers that you must/can include in your request to http-safe:

HeaderRequired?Value
X-SAFE-Target-URIYesThe URI of the target server.
X-SAFE-Accept-RegexYesA regular expression that must be matched by the status code replied by the target server.
X-SAFE-Max-RetriesNoNumber of resend attempts to perform if the first dispatch failed. Default is 0.
X-SAFE-Retry-IntervalYes if X-SAFE-Max-Retries > 0The number of minutes between two dispatch attempts. Must be >0 and <=60.
X-SAFE-Callback-URINoThe URI of a server to call in case of successfull or aborted (ie. all attempts failed) dispatch. http-safe will POST the entity received from the target server.

In addition to the X-SAFE-Correlation-Id header shown above, http-safe can add the following headers when it calls you back:

  • X-SAFE-Forward-Outcome: 'success' or 'failure',
  • X-SAFE-Forward-Status: the status code replied by the target server.

Limitations

  • The maximum size of an HTTP entity that can be stored-and-forwarded is 1MB.

Copyright 2011 - David Dossot - MIT License