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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.6 KiB
Markdown
Raw Permalink 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 yype: `x-recent-history`.
2011-05-06 19:38:48 +08:00
2014-03-27 03:52:32 +08:00
## Installation ##
This plugin ships with RabbitMQ.
2015-12-27 22:38:33 +08:00
Like all other plugins, it must be enabled before it can be used:
2015-04-14 22:10:24 +08:00
```bash
[sudo] rabbitmq-plugins enable rabbitmq_recent_history_exchange
2015-04-14 22:10:24 +08:00
```
2014-03-27 03:52:32 +08:00
## Usage ##
2014-03-27 03:05:06 +08:00
### Creating an exchange
2014-03-27 03:25:38 +08:00
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:25:38 +08:00
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
2014-03-27 03:05:06 +08:00
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.
## Disabling the Plugin
2014-03-27 03:32:29 +08:00
When you disable this plugin, it will delete all the cached messages.
2014-03-27 03:32:29 +08:00
2011-10-15 05:58:22 +08:00
## License
2011-05-06 19:38:48 +08:00
2020-03-09 15:48:26 +08:00
See LICENSE.