Merge pull request #4696 from rabbitmq/rabbitmq-jms-topic-exchange-return-empty-array-when-no-state

Return empty array when JMS topic exchange state does not exist
This commit is contained in:
Michael Klishin 2022-05-02 22:44:32 +04:00 committed by GitHub
commit 7975881cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 7 deletions

View File

@ -99,8 +99,12 @@ serialise_events() -> false.
route( #exchange{name = XName}
, #delivery{message = #basic_message{content = MessageContent, routing_keys = RKs}}
) ->
BindingFuns = get_binding_funs_x(XName),
match_bindings(XName, RKs, MessageContent, BindingFuns).
case get_binding_funs_x(XName) of
not_found ->
[];
BindingFuns ->
match_bindings(XName, RKs, MessageContent, BindingFuns)
end.
% Before exchange declaration
@ -232,8 +236,12 @@ selector_match(Selector, Headers) ->
get_binding_funs_x(XName) ->
mnesia:async_dirty(
fun() ->
#?JMS_TOPIC_RECORD{x_selector_funs = BindingFuns} = read_state(XName),
BindingFuns
case read_state_no_error(XName) of
not_found ->
not_found;
#?JMS_TOPIC_RECORD{x_selector_funs = BindingFuns} ->
BindingFuns
end
end,
[]
).
@ -266,9 +274,6 @@ delete_state(XName) ->
% Basic read for update
read_state_for_update(XName) -> read_state(XName, write).
% Basic read
read_state(XName) -> read_state(XName, read).
% Lockable read
read_state(XName, Lock) ->
case mnesia:read(?JMS_TOPIC_TABLE, XName, Lock) of
@ -276,6 +281,14 @@ read_state(XName, Lock) ->
_ -> exchange_state_corrupt_error(XName)
end.
read_state_no_error(XName) ->
case mnesia:read(?JMS_TOPIC_TABLE, XName, read) of
[Rec] -> Rec;
_ -> not_found
end.
% Basic write
write_state_fun(XName, BFuns) ->
mnesia:write( ?JMS_TOPIC_TABLE