Skip to content

Commit 5b83dce

Browse files
committed
Return only streams for partition-related commands
The stream partition metadata is based on bindings, so we make sure to return only streams from the binding information.
1 parent 04a0653 commit 5b83dce

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

deps/rabbitmq_stream/src/rabbit_stream_manager.erl

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,10 @@ handle_call({route, RoutingKey, VirtualHost, SuperStream}, _From,
369369
[] ->
370370
{ok, no_route};
371371
Routes ->
372-
%% FIXME filter non-stream resources
373-
{ok, [Stream || #resource{name = Stream} <- Routes]}
372+
{ok,
373+
[Stream
374+
|| #resource{name = Stream} = R <- Routes,
375+
is_resource_stream_queue(R)]}
374376
end
375377
catch
376378
exit:Error ->
@@ -383,10 +385,11 @@ handle_call({partitions, VirtualHost, SuperStream}, _From, State) ->
383385
ExchangeName = rabbit_misc:r(VirtualHost, exchange, SuperStream),
384386
Res = try
385387
rabbit_exchange:lookup_or_die(ExchangeName),
386-
%% FIXME make sure queue is a stream
387-
%% TODO bindings could be sorted by partition number, by using a binding argument
388-
%% this would make the spreading of messages stable
389-
UnorderedBindings = rabbit_binding:list_for_source(ExchangeName),
388+
UnorderedBindings =
389+
[Binding
390+
|| Binding = #binding{destination = D}
391+
<- rabbit_binding:list_for_source(ExchangeName),
392+
is_resource_stream_queue(D)],
390393
OrderedBindings =
391394
rabbit_stream_utils:sort_partitions(UnorderedBindings),
392395
{ok,
@@ -448,3 +451,13 @@ is_stream_queue(Q) ->
448451
_ ->
449452
false
450453
end.
454+
455+
is_resource_stream_queue(#resource{kind = queue} = Resource) ->
456+
case rabbit_amqqueue:lookup(Resource) of
457+
{ok, Q} ->
458+
is_stream_queue(Q);
459+
_ ->
460+
false
461+
end;
462+
is_resource_stream_queue(_) ->
463+
false.

0 commit comments

Comments
 (0)