rabbitmq-server/deps/rabbitmq_recent_history_exc.../README.md

53 lines
1.9 KiB
Markdown
Raw Normal View History

2011-05-06 19:38:48 +08:00
# RabbitMQ Recent History Cache
2011-10-15 05:58:22 +08:00
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.
2011-05-06 19:38:48 +08:00
Exchange Type: `x-recent-history`
2011-10-15 05:58:22 +08:00
## Installation
2011-05-06 19:38:48 +08:00
2011-10-15 05:58:22 +08:00
Install and setup the RabbitMQ Public Umbrella as explained here: [http://www.rabbitmq.com/plugin-development.html#getting-started](http://www.rabbitmq.com/plugin-development.html#getting-started).
Then `cd` into the umbrella folder and type:
$ git clone git://github.com/videlalvaro/rabbitmq-recent-history-exchange.git
$ cd rabbitmq-recent-history-exchange
$ make
2011-10-31 04:27:44 +08:00
Finally copy all the `*.ez` files inside the `dist` folder to the `$RABBITMQ_HOME/plugins` folder. Don't copy the file `rabbit_common-x.y.z` since it's not needed inside the broker installation.
2011-10-15 05:58:22 +08:00
## Usage
2014-03-27 03:05:06 +08:00
2014-03-27 03:25:38 +08:00
### Creating an exchange ###
To create a _recent history exchange_, just declare an exchange providing the type `"x-recent-history"`.
```java
channel.exchangeDeclare("logs", "x-recent-history");
```
### Providing a custom history length ###
2014-03-27 03:05:06 +08:00
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:
```java
Map<String, Object> args = new HashMap<String, Object>();
args.put("x-recent-history-length", 60);
2014-03-27 03:25:38 +08:00
channel.exchangeDeclare("rh", "x-recent-history", false, false, args);
2014-03-27 03:05:06 +08:00
```
### Preventing some messages from being stored ###
In case you would like to not store certain messages, just
2014-03-27 03:15:33 +08:00
add the header `"x-recent-history-no-store"` with the value `true` to
2014-03-27 03:05:06 +08:00
the message.
2011-10-15 05:58:22 +08:00
## License
2011-05-06 19:38:48 +08:00
See LICENSE.md