99% % The Original Code is RabbitMQ.
1010% %
1111% % The Initial Developer of the Original Code is Pivotal Software, Inc.
12+ <<<<<<< HEAD
1213% % Copyright (c) 2007-2025 Broadcom. All Rights Reserved.
14+ =======
15+ % % Copyright (c) 2020-2025 Broadcom. All Rights Reserved.
16+ >>>>>>> 69 d0382dd (Emit cancellation event only when stream consumer is cancelled )
1317% % The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
1418% %
1519
@@ -2249,7 +2253,7 @@ handle_frame_post_auth(Transport,
22492253 {Connection , State };
22502254 true ->
22512255 {Connection1 , State1 } =
2252- remove_subscription (SubscriptionId , Connection , State ),
2256+ remove_subscription (SubscriptionId , Connection , State , true ),
22532257 response_ok (Transport , Connection , unsubscribe , CorrelationId ),
22542258 {Connection1 , State1 }
22552259 end ;
@@ -3081,7 +3085,7 @@ evaluate_state_after_secret_update(Transport,
30813085 _ ->
30823086 {C1 , S1 } =
30833087 lists :foldl (fun (SubId , {Conn , St }) ->
3084- remove_subscription (SubId , Conn , St )
3088+ remove_subscription (SubId , Conn , St , false )
30853089 end , {C0 , S0 }, Subs ),
30863090 {Acc #{Str => ok }, C1 , S1 }
30873091 end
@@ -3216,7 +3220,8 @@ notify_connection_closed(#statem_data{connection =
32163220 ConnectionState }) ->
32173221 rabbit_core_metrics :connection_closed (self ()),
32183222 [rabbit_stream_metrics :consumer_cancelled (self (),
3219- stream_r (S , Connection ), SubId )
3223+ stream_r (S , Connection ),
3224+ SubId , false )
32203225 || # consumer {configuration =
32213226 # consumer_configuration {stream = S ,
32223227 subscription_id = SubId }}
@@ -3304,7 +3309,8 @@ clean_state_after_stream_deletion_or_failure(MemberPid, Stream,
33043309 rabbit_stream_metrics :consumer_cancelled (self (),
33053310 stream_r (Stream ,
33063311 C0 ),
3307- SubId ),
3312+ SubId ,
3313+ false ),
33083314 maybe_unregister_consumer (
33093315 VirtualHost , Consumer ,
33103316 single_active_consumer (Consumer ),
@@ -3314,7 +3320,8 @@ clean_state_after_stream_deletion_or_failure(MemberPid, Stream,
33143320 rabbit_stream_metrics :consumer_cancelled (self (),
33153321 stream_r (Stream ,
33163322 C0 ),
3317- SubId ),
3323+ SubId ,
3324+ false ),
33183325 maybe_unregister_consumer (
33193326 VirtualHost , Consumer ,
33203327 single_active_consumer (Consumer ),
@@ -3431,7 +3438,8 @@ remove_subscription(SubscriptionId,
34313438 stream_subscriptions =
34323439 StreamSubscriptions } =
34333440 Connection ,
3434- # stream_connection_state {consumers = Consumers } = State ) ->
3441+ # stream_connection_state {consumers = Consumers } = State ,
3442+ Notify ) ->
34353443 #{SubscriptionId := Consumer } = Consumers ,
34363444 # consumer {log = Log ,
34373445 configuration = # consumer_configuration {stream = Stream , member_pid = MemberPid }} =
@@ -3457,7 +3465,8 @@ remove_subscription(SubscriptionId,
34573465 Connection2 = maybe_clean_connection_from_stream (MemberPid , Stream , Connection1 ),
34583466 rabbit_stream_metrics :consumer_cancelled (self (),
34593467 stream_r (Stream , Connection2 ),
3460- SubscriptionId ),
3468+ SubscriptionId ,
3469+ Notify ),
34613470
34623471 Requests1 = maybe_unregister_consumer (
34633472 VirtualHost , Consumer ,
0 commit comments