rabbitmq-server/deps/rabbitmq_recent_history_exc...
Jean-Sébastien Pédron debe2a118c
rabbitmq_ct_helpers: Change how Mnesia/Khepri is selected
[Why]
Once `khepr_db` is enabled by default, we need another way to disable it
to select Mnesia instead.

[How]
We use the new relative forced feature flags mechanism to indicate if we
want to explicitly enable or disable `khepri_db`. This way, we don't
touch other stable feature flags and only mess with Khepri.

However, this mechanism is not supported by RabbitMQ 4.0.x and older.
They will ignore the setting. Therefore, to make this work in
mixed-version testing, we set the `$RABBITMQ_FEATURE_FLAGS` variable for
the secondary umbrella. This part will go away once we test against
RabbitMQ 4.1.x as the secondary umbrella in the future.

At the end, we compare the effective metadata store to the expected one.
If they don't match, we skip the test.

While here, change `rjms_topic_selector_SUITE` to only choose Khepri
without specifying any feature flags.
2024-12-17 09:56:54 +01:00
..
etc adds multinode tests 2014-09-23 19:16:25 +02:00
include More missed (c) header updates 2024-01-23 11:26:29 -05:00
src Reorganize data in the Khepri store 2024-09-05 15:31:29 +02:00
test rabbitmq_ct_helpers: Change how Mnesia/Khepri is selected 2024-12-17 09:56:54 +01:00
BUILD.bazel Allow to use Khepri database to store metadata instead of Mnesia 2023-09-29 16:00:11 +02:00
CODE_OF_CONDUCT.md Replace files with symlinks 2022-04-15 06:04:29 -07:00
CONTRIBUTING.md Replace files with symlinks 2022-04-15 06:04:29 -07:00
LICENSE Replace @rabbitmq.com addresses with rabbitmq-core@groups.vmware.com 2023-06-20 15:40:13 +04:00
LICENSE-MPL-RabbitMQ Revert drop of Exhibit B on MPL 2.0 2020-07-20 17:03:05 +01:00
Makefile Set PLT_APPS in a number of plugins where it was missing 2024-04-29 14:54:28 +02:00
README.md Minor update in README of recent history exchange 2024-11-19 11:44:58 +01:00
app.bzl Allow to use Khepri database to store metadata instead of Mnesia 2023-09-29 16:00:11 +02: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 yype: x-recent-history.

Installation

This plugin ships with RabbitMQ.

Like all other plugins, it must be enabled before it can be used:

[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

When you disable this plugin, it will delete all the cached messages.

License

See LICENSE.