rabbitmq-server/deps/rabbitmq_recent_history_exc...
Michal Kuratczyk 1a2126676d Update CLA URL 2021-09-23 14:29:36 +02:00
..
etc adds multinode tests 2014-09-23 19:16:25 +02:00
include Bump (c) year in header files 2021-02-04 07:04:58 +03:00
src {consistent_hash,recent_history}_exchange plugins: add retries to schema sync 2021-05-26 20:49:14 +03:00
test Bump (c) year 2021-01-22 09:00:14 +03:00
.gitignore Git: Ignore copied CLI 2019-12-12 15:04:35 +01:00
.travis.yml Travis CI: Update config from rabbitmq-common 2020-03-04 14:24:31 +01:00
BUILD.bazel Also assert no missing suites for all other deps 2021-07-12 18:05:55 +02:00
CODE_OF_CONDUCT.md URL Cleanup 2019-03-20 03:21:02 -05:00
CONTRIBUTING.md Update CLA URL 2021-09-23 14:29:36 +02:00
LICENSE Update LICENSE 2020-07-20 12:08:32 +01:00
LICENSE-MPL-RabbitMQ Revert drop of Exhibit B on MPL 2.0 2020-07-20 17:03:05 +01:00
Makefile Remove duplicate rabbitmq-components.mk and erlang.mk files 2021-03-22 15:40:19 +01:00
README.md Merge branch 'master' into polish-urls-remaining-master 2020-03-09 11:17:20 +03:00

README.md

RabbitMQ Recent History Cache

Keeps track of the last 20 messages that passed through the exchange. Every time a queue is bound to the exchange it delivers that last 20 messages to them. This is useful for implementing a very simple Chat History where clients that join the conversation can get the latest messages.

Exchange Type: x-recent-history

Installation

RabbitMQ 3.6.0 or later

As of RabbitMQ 3.6.0 this plugin is included into the RabbitMQ distribution.

Enable it with the following command:

rabbitmq-plugins enable rabbitmq_recent_history_exchange

With Earlier Versions

Install the corresponding .ez files from our Community Plugins archive..

Then run the following command:

rabbitmq-plugins enable rabbitmq_recent_history_exchange

Building from Source

Please see RabbitMQ Plugin Development guide.

To build the plugin:

git clone git://github.com/rabbitmq/rabbitmq-recent-history-exchange.git
cd rabbitmq-recent-history-exchange
make

Then copy all the *.ez files inside the plugins folder to the RabbitMQ plugins directory and enable the plugin:

[sudo] rabbitmq-plugins enable rabbitmq_recent_history_exchange

Usage

Creating an exchange

To create a recent history exchange, just declare an exchange providing the type "x-recent-history".

channel.exchangeDeclare("logs", "x-recent-history");

Providing a custom history length

Typically this exchange will store the latest 20 messages sent over the exchange. If you want to set a different cache length, then you can pass a "x-recent-history-length" argument to exchange.declare. The argument must be an integer greater or equal to zero.

For example in Java:

Map<String, Object> args = new HashMap<String, Object>();
args.put("x-recent-history-length", 60);
channel.exchangeDeclare("rh", "x-recent-history", false, false, args);

Preventing some messages from being stored

In case you would like to not store certain messages, just add the header "x-recent-history-no-store" with the value true to the message.

Disabling the Plugin

A future version of RabbitMQ will allow users to disable plugins. When you disable this plugin, it will delete all the cached messages.

License

See LICENSE.