Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define PROJECT_ENV
endef

define PROJECT_APP_EXTRA_KEYS
{broker_version_requirements, ["3.7.0", "3.8.0"]}
{broker_version_requirements, ["4.1.0"]}
endef

LOCAL_DEPS = inets
Expand Down
2 changes: 1 addition & 1 deletion helpers.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_erlang//:ct.bzl", "ct_test")

BROKER_VERSION_REQUIREMENTS_TERM = """{broker_version_requirements, ["3.13.0"]}"""
BROKER_VERSION_REQUIREMENTS_TERM = """{broker_version_requirements, ["4.1.0"]}"""

def rabbitmq_suite(
name = None,
Expand Down
21 changes: 13 additions & 8 deletions src/rabbit_exchange_type_management.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
-module(rabbit_exchange_type_management).
-include_lib("rabbit_common/include/rabbit.hrl").
-include_lib("rabbit_common/include/rabbit_framing.hrl").

-include_lib("rabbit/include/mc.hrl").
-behaviour(rabbit_exchange_type).

-export([description/0, serialise_events/0, route/2]).
-export([description/0, serialise_events/0, route/2, route/3]).
-export([validate/1, validate_binding/2,
create/2, delete/2, policy_changed/2,
add_binding/3, remove_bindings/3, assert_args_equivalence/2]).
Expand All @@ -37,9 +37,12 @@ description() ->

serialise_events() -> false.

route(#exchange{name = #resource{virtual_host = VHost}},
#delivery{message = #basic_message{routing_keys = Keys,
content = Content0}}) ->
route(Exchange, _Message) ->
route(Exchange, _Message, #{}).

route(#exchange{name = #resource{virtual_host = VHost}},Msg,_Opts) ->
Keys = mc:routing_keys(Msg),
Content0 = mc:protocol_state(mc:convert(mc_amqpl, Msg)),
#content{properties = #'P_basic'{reply_to = ReplyTo,
type = Method,
correlation_id = Id},
Expand All @@ -52,6 +55,7 @@ route(#exchange{name = #resource{virtual_host = VHost}},
[handle_rpc(Method, K, Id, VHost, ReplyTo, Payload) || K <- Keys],
[]. %% Don't route anything!


validate(_X) -> ok.

validate_binding(_X, _B) -> {error, {'binding_invalid', "cannot_bind_to_management_exchange", []}}.
Expand Down Expand Up @@ -87,11 +91,12 @@ handle_rpc(Method, Path, Id, VHost, ReplyTo, ReqBody) ->
type = list_to_binary(integer_to_list(Code)),
content_type = <<"application/json">>},
Content = rabbit_basic:build_content(Props, [list_to_binary(ResBody)]),
{ok, Msg} = rabbit_basic:message(rabbit_misc:r(VHost, exchange, <<>>),
ReplyTo, Content),
_ = rabbit_basic:publish(rabbit_basic:delivery(false, false, Msg, undefined)),
ExchangeDst = rabbit_misc:r(VHost, exchange, <<>>),
{ok, Msg} = mc_amqpl:message(ExchangeDst, ReplyTo, Content),
_ = rabbit_queue_type:publish_at_most_once(ExchangeDst,Msg),
ok;
{error, Reason} ->
error_logger:info_msg("Management exchange error:~p~n ",Reason),
exit({error, Reason})
end.

Expand Down