Skip to content

Commit 5159fd6

Browse files
ansdmergify[bot]
authored andcommitted
Move x-modulus-hash exchange to rabbit
Move the x-modulus-hash exchange type from rabbitmq_sharding to rabbit since this exchange type is useful even without the sharding plugin. (cherry picked from commit 1229705)
1 parent fc41aff commit 5159fd6

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

deps/rabbit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ PARALLEL_CT_SET_4_D = per_user_connection_channel_tracking product_info queue_ty
271271
PARALLEL_CT_SET_5_A = rabbit_direct_reply_to_prop rabbit_quorum_queue_prop direct_reply_to_amqpl direct_reply_to_amqp classic_queue
272272
PARALLEL_CT_SET_5_B = feature_flags_v2 backing_queue transactions
273273
PARALLEL_CT_SET_5_C = cluster_upgrade maintenance_mode
274-
PARALLEL_CT_SET_5_D = rabbit_fifo_dlx_integration publisher_confirms_parallel
274+
PARALLEL_CT_SET_5_D = rabbit_fifo_dlx_integration publisher_confirms_parallel rabbit_exchange_type_modulus_hash
275275

276276
PARALLEL_CT_SET_1 = $(sort $(PARALLEL_CT_SET_1_A) $(PARALLEL_CT_SET_1_B) $(PARALLEL_CT_SET_1_C) $(PARALLEL_CT_SET_1_D))
277277
PARALLEL_CT_SET_2 = $(sort $(PARALLEL_CT_SET_2_A) $(PARALLEL_CT_SET_2_B) $(PARALLEL_CT_SET_2_C) $(PARALLEL_CT_SET_2_D))

deps/rabbitmq_sharding/src/rabbit_sharding_exchange_type_modulus_hash.erl renamed to deps/rabbit/src/rabbit_exchange_type_modulus_hash.erl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
%% Copyright (c) 2007-2026 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66
%%
77

8-
-module(rabbit_sharding_exchange_type_modulus_hash).
9-
10-
-include_lib("rabbit_common/include/rabbit.hrl").
8+
-module(rabbit_exchange_type_modulus_hash).
119

1210
-behaviour(rabbit_exchange_type).
1311

12+
-include_lib("rabbit_common/include/rabbit.hrl").
13+
1414
-export([description/0,
1515
route/3,
1616
serialise_events/0,
@@ -25,13 +25,12 @@
2525
remove_bindings/3,
2626
assert_args_equivalence/2]).
2727

28-
-rabbit_boot_step(
29-
{rabbit_sharding_exchange_type_modulus_hash_registry,
30-
[{description, "exchange type x-modulus-hash: registry"},
31-
{mfa, {rabbit_registry, register, [exchange, <<"x-modulus-hash">>, ?MODULE]}},
32-
{cleanup, {rabbit_registry, unregister, [exchange, <<"x-modulus-hash">>]}},
33-
{requires, rabbit_registry},
34-
{enables, kernel_ready}]}).
28+
-rabbit_boot_step({?MODULE,
29+
[{description, "exchange type x-modulus-hash"},
30+
{mfa, {rabbit_registry, register,
31+
[exchange, <<"x-modulus-hash">>, ?MODULE]}},
32+
{requires, rabbit_registry},
33+
{enables, kernel_ready}]}).
3534

3635
%% 2^27
3736
-define(PHASH2_RANGE, 134217728).

deps/rabbitmq_sharding/test/rabbit_hash_exchange_SUITE.erl renamed to deps/rabbit/test/rabbit_exchange_type_modulus_hash_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%%
55
%% Copyright (c) 2007-2026 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66
%%
7-
-module(rabbit_hash_exchange_SUITE).
7+
-module(rabbit_exchange_type_modulus_hash_SUITE).
88

99
-compile(export_all).
1010

deps/rabbitmq_sharding/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,10 @@ Do not use this plugin with quorum queues. Avoid classic mirrored queues in gene
4848

4949
## Messages Distribution Between Shards (Partitioning)
5050

51-
The exchanges that ship by default with RabbitMQ work in an "all or
52-
nothing" fashion, i.e: if a routing key matches a set of queues bound
53-
to the exchange, then RabbitMQ will route the message to all the
54-
queues in that set. For this plugin to work it is necessary to
55-
route messages to an exchange that would partition messages, so they
56-
are routed to _at most_ one queue (a subset).
57-
58-
The plugin provides a new exchange type, `"x-modulus-hash"`, that will use
51+
RabbitMQ provides a built-in exchange type, `"x-modulus-hash"`, that will use
5952
a hashing function to partition messages routed to a logical queue
60-
across a number of regular queues (shards).
53+
across a number of regular queues (shards). This exchange type is available
54+
in core RabbitMQ and does not require enabling this plugin to be used.
6155

6256
The `"x-modulus-hash"` exchange will hash the routing key used to
6357
publish the message and then it will apply a `Hash mod N` to pick the

0 commit comments

Comments
 (0)