3030 adapter_info , send_fun , ssl_login_name , peer_addr ,
3131 % % see rabbitmq/rabbitmq-stomp#39
3232 trailing_lf , auth_mechanism , auth_login ,
33- default_topic_exchange , default_nack_requeue }).
33+ default_topic_exchange , default_nack_requeue ,
34+ virtual_host }).
3435
3536-record (subscription , {dest_hdr , ack_mode , multi_ack , description }).
3637
@@ -152,7 +153,7 @@ initial_state(Configuration,
152153 version = none ,
153154 pending_receipts = undefined ,
154155 config = Configuration ,
155- route_state = rabbit_routing_util :init_state (),
156+ route_state = rabbit_stomp_routing_util :init_state (),
156157 reply_queues = #{},
157158 frame_transformer = undefined ,
158159 trailing_lf = application :get_env (rabbitmq_stomp , trailing_lf , true ),
@@ -556,7 +557,7 @@ with_destination(Command, Frame, State, Fun) ->
556557 " '~ts ' is not a valid destination.~n "
557558 " Valid destination types are: ~ts .~n " ,
558559 [Content ,
559- string :join (rabbit_routing_util :all_dest_prefixes (),
560+ string :join (rabbit_stomp_routing_util :all_dest_prefixes (),
560561 " , " )], State )
561562 end ;
562563 not_found ->
@@ -606,10 +607,11 @@ do_login(Username, Passwd, VirtualHost, Heartbeat, AdapterInfo, Version,
606607 false -> [{? HEADER_SERVER , server_header ()} | Headers ]
607608 end ,
608609 " " ,
609- State # proc_state {session_id = SessionId ,
610- channel = Channel ,
611- connection = Connection ,
612- version = Version });
610+ State # proc_state {session_id = SessionId ,
611+ channel = Channel ,
612+ connection = Connection ,
613+ version = Version ,
614+ virtual_host = VirtualHost });
613615 {error , {auth_failure , _ }} ->
614616 ? LOG_WARNING (" STOMP login failed for user '~ts ': authentication failed" , [Username ]),
615617 error (" Bad CONNECT" , " Access refused for user '" ++
@@ -650,15 +652,14 @@ server_header() ->
650652
651653do_subscribe (Destination , DestHdr , Frame ,
652654 State = # proc_state {subscriptions = Subs ,
653- route_state = RouteState ,
654655 channel = Channel ,
655656 default_topic_exchange = DfltTopicEx }) ->
656657 check_subscription_access (Destination , State ),
657658 Prefetch =
658659 rabbit_stomp_frame :integer_header (Frame , ? HEADER_PREFETCH_COUNT ,
659660 undefined ),
660661 {AckMode , IsMulti } = rabbit_stomp_util :ack_mode (Frame ),
661- case ensure_endpoint (source , Destination , Frame , Channel , RouteState ) of
662+ case ensure_endpoint (source , Destination , Frame , Channel , State ) of
662663 {ok , Queue , RouteState1 } ->
663664 {ok , ConsumerTag , Description } =
664665 rabbit_stomp_util :consumer_tag (Frame ),
@@ -687,7 +688,7 @@ do_subscribe(Destination, DestHdr, Frame,
687688 exclusive = false ,
688689 arguments = Arguments },
689690 self ()),
690- ok = rabbit_routing_util :ensure_binding (
691+ ok = rabbit_stomp_routing_util :ensure_binding (
691692 Queue , ExchangeAndKey , Channel )
692693 catch exit :Err ->
693694 % % it's safe to delete this queue, it
@@ -788,9 +789,8 @@ maybe_clean_up_queue(Queue, #proc_state{connection = Connection}) ->
788789do_send (Destination , _DestHdr ,
789790 Frame = # stomp_frame {body_iolist = BodyFragments },
790791 State = # proc_state {channel = Channel ,
791- route_state = RouteState ,
792792 default_topic_exchange = DfltTopicEx }) ->
793- case ensure_endpoint (dest , Destination , Frame , Channel , RouteState ) of
793+ case ensure_endpoint (dest , Destination , Frame , Channel , State ) of
794794
795795 {ok , _Q , RouteState1 } ->
796796
@@ -912,7 +912,7 @@ ensure_reply_to(Frame = #stomp_frame{headers = Headers}, State) ->
912912 {Frame , State };
913913 {ok , ReplyTo } ->
914914 {ok , Destination } = rabbit_routing_parser :parse_endpoint (ReplyTo ),
915- case rabbit_routing_util :dest_temp_queue (Destination ) of
915+ case rabbit_stomp_routing_util :dest_temp_queue (Destination ) of
916916 none ->
917917 {Frame , State };
918918 TempQueueId ->
@@ -1128,7 +1128,8 @@ millis_to_seconds(M) -> M div 1000.
11281128ensure_endpoint (_Direction , {queue , []}, _Frame , _Channel , _State ) ->
11291129 {error , {invalid_destination , " Destination cannot be blank" }};
11301130
1131- ensure_endpoint (source , EndPoint , {_ , _ , Headers , _ } = Frame , Channel , State ) ->
1131+ ensure_endpoint (source , EndPoint , {_ , _ , Headers , _ } = Frame , Channel ,
1132+ # proc_state {virtual_host = VHost , route_state = RouteState }) ->
11321133 Params =
11331134 [{subscription_queue_name_gen ,
11341135 fun () ->
@@ -1138,16 +1139,20 @@ ensure_endpoint(source, EndPoint, {_, _, Headers, _} = Frame, Channel, State) ->
11381139 {_ , Name } = rabbit_routing_parser :parse_routing (EndPoint ),
11391140 list_to_binary (rabbit_stomp_util :subscription_queue_name (Name , Id , Frame ))
11401141 end
1141- }] ++ rabbit_stomp_util :build_params (EndPoint , Headers ),
1142+ },
1143+ {default_queue_type , rabbit_vhost :default_queue_type (VHost )}]
1144+ ++ rabbit_stomp_util :build_params (EndPoint , Headers ),
11421145 Arguments = rabbit_stomp_util :build_arguments (Headers ),
1143- rabbit_routing_util :ensure_endpoint (source , Channel , EndPoint ,
1144- [Arguments | Params ], State );
1146+ rabbit_stomp_routing_util :ensure_endpoint (source , Channel , EndPoint ,
1147+ [Arguments | Params ], RouteState );
11451148
1146- ensure_endpoint (Direction , EndPoint , {_ , _ , Headers , _ }, Channel , State ) ->
1147- Params = rabbit_stomp_util :build_params (EndPoint , Headers ),
1149+ ensure_endpoint (Direction , EndPoint , {_ , _ , Headers , _ }, Channel ,
1150+ # proc_state {virtual_host = VHost , route_state = RouteState }) ->
1151+ Params = [{default_queue_type , rabbit_vhost :default_queue_type (VHost )}
1152+ | rabbit_stomp_util :build_params (EndPoint , Headers )],
11481153 Arguments = rabbit_stomp_util :build_arguments (Headers ),
1149- rabbit_routing_util :ensure_endpoint (Direction , Channel , EndPoint ,
1150- [Arguments | Params ], State ).
1154+ rabbit_stomp_routing_util :ensure_endpoint (Direction , Channel , EndPoint ,
1155+ [Arguments | Params ], RouteState ).
11511156
11521157build_subscription_id (Frame ) ->
11531158 case rabbit_stomp_util :has_durable_header (Frame ) of
0 commit comments