26
26
check_options /0 ,
27
27
handle_ack /3 ]).
28
28
29
-
29
+ - define ( VHOST_DEFAULT , << " / " >>).
30
30
-define (QUEUE_TYPES , [<<" classic" >>, <<" quorum" >>, <<>>]).
31
31
32
32
% % state for direct publish mode
@@ -89,6 +89,8 @@ options() -> [
89
89
{pass , string , {amqp , pass }},
90
90
{ssl , is_set , false },
91
91
{vhost , string , <<" /" >>},
92
+ % % only applies, if vhost is NOT the default: '/', applies to both vhost params
93
+ {vhost_prefix , string , {rabbitmq , vhost_prefix }},
92
94
{routing_key , string , undefined },
93
95
{bindings , string_list , undefined },
94
96
{qx_name , string , undefined }, % % not used currently
@@ -137,9 +139,9 @@ metrics() ->
137
139
].
138
140
139
141
init ({GraphId , NodeId } = Idx , _Ins ,
140
- #{ host := Host0 , port := Port , user := _User , pass := _Pass , vhost := VHost , queue := Q0 , queue_type := QType0 ,
142
+ #{ host := Host0 , port := Port , user := _User , pass := _Pass , vhost := VHost0 , queue := Q0 , queue_type := QType0 ,
141
143
exchange := Ex0 , qx_name := _QxName , prefetch := Prefetch , routing_key := RoutingKey0 , bindings := Bindings0 ,
142
- dt_field := DTField , dt_format := DTFormat , ssl := UseSSL , include_topic := IncludeTopic ,
144
+ dt_field := DTField , dt_format := DTFormat , ssl := UseSSL , include_topic := IncludeTopic , vhost_prefix : = VHostPrefix ,
143
145
topic_as := TopicKey , ack_every := AckEvery0 , ack_after := AckTimeout0 , as := As , consumer_tag := CTag0 ,
144
146
queue_prefix := QPrefix , root_exchange := RExchange , exchange_prefix := XPrefix
145
147
, use_flow_ack := FlowAck , clean_field_names := Clean ,
@@ -150,6 +152,7 @@ init({GraphId, NodeId} = Idx, _Ins,
150
152
'_parent_pid' := ParentPid , '_parent_subscriptions' := ParentSubs , passive := Passive
151
153
} = Opts0 ) ->
152
154
155
+ VHost = case VHost0 of ? VHOST_DEFAULT -> VHost0 ; _ -> faxe_util :prefix_binary (VHost0 , VHostPrefix ) end ,
153
156
% % lager:warning("opts ~p", [Opts0]),
154
157
Q = eval_name (Q0 , Opts0 , Idx ),
155
158
QName = faxe_util :prefix_binary (Q , QPrefix ),
@@ -205,14 +208,14 @@ init({GraphId, NodeId} = Idx, _Ins,
205
208
% % lager:info("opts before: ~p",[Opts0]),
206
209
207
210
Opts = Opts0 #{
208
- host => Host , consumer_tag => CTag ,
211
+ host => Host , consumer_tag => CTag , vhost => VHost ,
209
212
exchange => faxe_util :prefix_binary (Ex , XPrefix ),
210
213
root_exchange => case RExchange of undefined -> undefined ; _ -> RExchange end ,
211
214
queue => QName , queue_type => QType ,
212
215
routing_key => faxe_util :to_rkey (RoutingKey0 ),
213
216
bindings => faxe_util :to_rkey (Bindings0 )
214
217
},
215
- % % lager:info("opts: ~p",[Opts]),
218
+ lager :info (" opts: ~p " ,[Opts ]),
216
219
217
220
State = State1 # state {
218
221
opts = Opts , ack_after = AckTimeout , queue_type = QType ,
@@ -236,8 +239,13 @@ check_unique_q(_, _) ->
236
239
237
240
init_takeover_consumer (ParentPid , IdxParent , CTag ,
238
241
Opts = #{takeover_queue := Q0 , takeover_queue_type := QType0 , '_name' := Name , takeover_queue_vhost := TVHost ,
239
- vhost := VHost }) ->
240
- TakeoverVHost = case TVHost of undefined -> VHost ; _ -> TVHost end ,
242
+ vhost := VHost , vhost_prefix := VHostPrefix }) ->
243
+ TakeoverVHost0 = case TVHost of undefined -> VHost ; _ -> TVHost end ,
244
+ TakeoverVHost =
245
+ case TakeoverVHost0 of
246
+ ? VHOST_DEFAULT -> TakeoverVHost0 ;
247
+ _ -> faxe_util :prefix_binary (TakeoverVHost0 , VHostPrefix )
248
+ end ,
241
249
NewOpts = Opts #{
242
250
% % do not use esq for takeover
243
251
safe => false ,
0 commit comments