@@ -340,46 +340,49 @@ process_connect(Implicit, Frame,
340
340
{? HEADER_HEART_BEAT ,
341
341
io_lib :format (" ~B ,~B " , [SendTimeout , ReceiveTimeout ])},
342
342
{? HEADER_VERSION , Version }],
343
- ok ('CONNECTED' ,
344
- case application :get_env (rabbitmq_stomp , hide_server_info , false ) of
345
- true -> Headers ;
346
- false -> [{? HEADER_SERVER , server_header ()} | Headers ]
347
- end ,
348
- " " ,
349
- StateN1 # state {cfg = # cfg {
343
+
344
+ Res = ok (" CONNECTED" ,
345
+ case application :get_env (rabbitmq_stomp , hide_server_info , false ) of
346
+ true -> Headers ;
347
+ false -> [{? HEADER_SERVER , server_header ()} | Headers ]
348
+ end ,
349
+ " " ,
350
+ StateN1 # state {cfg = # cfg {
350
351
session_id = SessionId ,
351
- version = Version
352
- },
353
- user = User ,
354
- authz_ctx = AuthzCtx })
352
+ version = Version
353
+ },
354
+ user = User ,
355
+ authz_ctx = AuthzCtx }),
356
+ self () ! connection_created ,
357
+ Res
355
358
else
356
359
{error , no_common_version } ->
357
360
error (" Version mismatch" ,
358
361
" Supported versions are ~ts~n " ,
359
362
[string :join (? SUPPORTED_VERSIONS , " ," )],
360
363
StateN );
361
- {error , not_allowed } ->
364
+ {error , not_allowed , EUsername , EVHost } ->
362
365
rabbit_log :warning (" STOMP login failed for user '~ts ': "
363
- " virtual host access not allowed" , [Username ]),
366
+ " virtual host access not allowed" , [EUsername ]),
364
367
error (" Bad CONNECT" , " Virtual host '" ++
365
- binary_to_list (VHost ) ++
368
+ binary_to_list (EVHost ) ++
366
369
" ' access denied" , State );
367
370
{refused , Username1 , _Msg , _Args } ->
368
371
rabbit_log :warning (" STOMP login failed for user '~ts ': authentication failed" , [Username1 ]),
369
372
error (" Bad CONNECT" , " Access refused for user '" ++
370
373
binary_to_list (Username1 ) ++ " '" , [], State );
371
- {error , not_loopback } ->
374
+ {error , not_loopback , EUsername } ->
372
375
rabbit_log :warning (" STOMP login failed for user '~ts ': "
373
- " this user's access is restricted to localhost" , [Username ]),
376
+ " this user's access is restricted to localhost" , [EUsername ]),
374
377
error (" Bad CONNECT" , " non-loopback access denied" , State )
375
- end ,
378
+ end
376
379
case {Res , Implicit } of
377
380
{{ok , _ , StateN2 }, implicit } ->
378
381
self () ! connection_created , ok (StateN2 );
379
382
_ ->
380
383
self () ! connection_created , Res
381
- end
382
- end ,
384
+
385
+ end ,
383
386
State ).
384
387
385
388
creds (_ , _ , # cfg {default_login = DefLogin ,
@@ -912,16 +915,6 @@ do_send(Destination, _DestHdr,
912
915
913
916
io :format (" Message: ~p~n " , [Message ]),
914
917
915
- % % {ok, BasicMessage} = rabbit_basic:message(ExchangeName, RoutingKey, Content),
916
-
917
- % % Delivery = #delivery{
918
- % % mandatory = false,
919
- % % confirm = DoConfirm,
920
- % % sender = self(),
921
- % % message = BasicMessage,
922
- % % msg_seq_no = MsgSeqNo,
923
- % % flow = Flow
924
- % % },
925
918
QNames = rabbit_exchange :route (Exchange , Message , #{return_binding_keys => true }),
926
919
io :format (" QNames ~p~n " , [QNames ]),
927
920
@@ -1318,8 +1311,11 @@ ensure_reply_queue(TempQueueId, State = #state{reply_queues = RQS,
1318
1311
# resource {name = QNameBin } = QName = amqqueue :get_name (Queue ),
1319
1312
1320
1313
ConsumerTag = rabbit_stomp_util :consumer_tag_reply_to (TempQueueId ),
1314
+
1315
+
1316
+ {ok , {_Global , DefaultPrefetch }} = application :get_env (rabbit , default_consumer_prefetch ),
1321
1317
Spec = #{no_ack => true ,
1322
- prefetch_count => application : get_env ( rabbit , default_consumer_prefetch ) ,
1318
+ prefetch_count => DefaultPrefetch ,
1323
1319
consumer_tag => ConsumerTag ,
1324
1320
exclusive_consume => false ,
1325
1321
args => []},
@@ -1718,7 +1714,6 @@ check_resource_access(User, Resource, Perm, Context) ->
1718
1714
1719
1715
handle_down ({{'DOWN' , QName }, _MRef , process , QPid , Reason },
1720
1716
State0 = # state {queue_states = QStates0 } = State ) ->
1721
- credit_flow :peer_down (QPid ),
1722
1717
case rabbit_queue_type :handle_down (QPid , QName , Reason , QStates0 ) of
1723
1718
{ok , QStates1 , Actions } ->
1724
1719
State1 = State0 # state {queue_states = QStates1 },
@@ -1782,13 +1777,6 @@ handle_queue_actions(Actions, #state{} = State0) ->
1782
1777
record_rejects (Rej , S );
1783
1778
({queue_down , QRef }, S0 ) ->
1784
1779
handle_consuming_queue_down_or_eol (QRef , S0 );
1785
- % % TODO: I have no idea about the scope of credit_flow
1786
- ({block , QName }, S0 ) ->
1787
- credit_flow :block (QName ),
1788
- S0 ;
1789
- ({unblock , QName }, S0 ) ->
1790
- credit_flow :unblock (QName ),
1791
- S0 ;
1792
1780
% % TODO: in rabbit_channel there code for handling
1793
1781
% % send_drained and send_credit_reply
1794
1782
% % I'm doing catch all here to not crash?
0 commit comments