@@ -1006,6 +1006,9 @@ open(cast,
1006
1006
Consumer ,
1007
1007
SendFileOct )
1008
1008
of
1009
+ {error , closed } ->
1010
+ rabbit_log :info (" Stream protocol connection has been closed by peer" , []),
1011
+ throw ({stop , connection_closed });
1009
1012
{error , Reason } ->
1010
1013
rabbit_log_connection :info (" Error while sending chunks: ~p " ,
1011
1014
[Reason ]),
@@ -1819,52 +1822,56 @@ handle_frame_post_auth(Transport,
1819
1822
1820
1823
rabbit_log :debug (" Distributing existing messages to subscription ~p " ,
1821
1824
[SubscriptionId ]),
1822
- {{segment , Segment1 }, {credit , Credit1 }} =
1823
- send_chunks (Transport , ConsumerState ,
1824
- SendFileOct ),
1825
- ConsumerState1 =
1826
- ConsumerState # consumer {segment = Segment1 ,
1827
- credit = Credit1 },
1828
- Consumers1 =
1829
- Consumers #{SubscriptionId => ConsumerState1 },
1830
-
1831
- StreamSubscriptions1 =
1832
- case StreamSubscriptions of
1833
- #{Stream := SubscriptionIds } ->
1834
- StreamSubscriptions #{Stream =>
1825
+
1826
+ case send_chunks (Transport , ConsumerState , SendFileOct ) of
1827
+ {error , closed } ->
1828
+ rabbit_log :info (" Stream protocol connection has been closed by peer" , []),
1829
+ throw ({stop , connection_closed });
1830
+ {{segment , Segment1 }, {credit , Credit1 }} ->
1831
+ ConsumerState1 =
1832
+ ConsumerState # consumer {segment = Segment1 ,
1833
+ credit = Credit1 },
1834
+ Consumers1 =
1835
+ Consumers #{SubscriptionId => ConsumerState1 },
1836
+
1837
+ StreamSubscriptions1 =
1838
+ case StreamSubscriptions of
1839
+ #{Stream := SubscriptionIds } ->
1840
+ StreamSubscriptions #{Stream =>
1835
1841
[SubscriptionId ]
1836
1842
++ SubscriptionIds };
1837
- _ ->
1838
- StreamSubscriptions #{Stream =>
1843
+ _ ->
1844
+ StreamSubscriptions #{Stream =>
1839
1845
[SubscriptionId ]}
1840
- end ,
1841
-
1842
- # consumer {counters = ConsumerCounters1 } =
1843
- ConsumerState1 ,
1844
-
1845
- ConsumerOffset = osiris_log :next_offset (Segment1 ),
1846
- ConsumerOffsetLag =
1847
- consumer_i (offset_lag , ConsumerState1 ),
1848
-
1849
- rabbit_log :debug (" Subscription ~p is now at offset ~p with ~p message(s) "
1850
- " distributed after subscription" ,
1851
- [SubscriptionId , ConsumerOffset ,
1852
- messages_consumed (ConsumerCounters1 )]),
1853
-
1854
- rabbit_stream_metrics :consumer_created (self (),
1855
- stream_r (Stream ,
1856
- Connection1 ),
1857
- SubscriptionId ,
1858
- Credit1 ,
1859
- messages_consumed (ConsumerCounters1 ),
1860
- ConsumerOffset ,
1861
- ConsumerOffsetLag ,
1862
- Properties ),
1863
- {Connection1 # stream_connection {stream_subscriptions
1864
- =
1865
- StreamSubscriptions1 },
1866
- State # stream_connection_state {consumers =
1867
- Consumers1 }}
1846
+ end ,
1847
+
1848
+ # consumer {counters = ConsumerCounters1 } =
1849
+ ConsumerState1 ,
1850
+
1851
+ ConsumerOffset = osiris_log :next_offset (Segment1 ),
1852
+ ConsumerOffsetLag =
1853
+ consumer_i (offset_lag , ConsumerState1 ),
1854
+
1855
+ rabbit_log :debug (" Subscription ~p is now at offset ~p with ~p message(s) "
1856
+ " distributed after subscription" ,
1857
+ [SubscriptionId , ConsumerOffset ,
1858
+ messages_consumed (ConsumerCounters1 )]),
1859
+
1860
+ rabbit_stream_metrics :consumer_created (self (),
1861
+ stream_r (Stream ,
1862
+ Connection1 ),
1863
+ SubscriptionId ,
1864
+ Credit1 ,
1865
+ messages_consumed (ConsumerCounters1 ),
1866
+ ConsumerOffset ,
1867
+ ConsumerOffsetLag ,
1868
+ Properties ),
1869
+ {Connection1 # stream_connection {stream_subscriptions
1870
+ =
1871
+ StreamSubscriptions1 },
1872
+ State # stream_connection_state {consumers =
1873
+ Consumers1 }}
1874
+ end
1868
1875
end
1869
1876
end ;
1870
1877
error ->
@@ -1893,22 +1900,8 @@ handle_frame_post_auth(Transport,
1893
1900
SendFileOct )
1894
1901
of
1895
1902
{error , closed } ->
1896
- rabbit_log :warning (" Stream protocol connection for subscription ~p has been closed, removing "
1897
- " subscription" ,
1898
- [SubscriptionId ]),
1899
- {Connection1 , State1 } =
1900
- remove_subscription (SubscriptionId , Connection , State ),
1901
-
1902
- Code = ? RESPONSE_CODE_SUBSCRIPTION_ID_DOES_NOT_EXIST ,
1903
- Frame =
1904
- rabbit_stream_core :frame ({response , 1 ,
1905
- {credit , Code ,
1906
- SubscriptionId }}),
1907
- send (Transport , S , Frame ),
1908
- rabbit_global_counters :increase_protocol_counter (stream ,
1909
- ? SUBSCRIPTION_ID_DOES_NOT_EXIST ,
1910
- 1 ),
1911
- {Connection1 , State1 };
1903
+ rabbit_log :warning (" Stream protocol connection has been closed by peer" , []),
1904
+ throw ({stop , connection_closed });
1912
1905
{{segment , Segment1 }, {credit , Credit1 }} ->
1913
1906
Consumer1 =
1914
1907
Consumer # consumer {segment = Segment1 , credit = Credit1 },
0 commit comments