27
27
-export ([has_for_source /1 , remove_for_source /1 ,
28
28
remove_for_destination /2 , remove_transient_for_destination /1 ]).
29
29
30
+ -define (DEFAULT_EXCHANGE (VHostPath ), # resource {virtual_host = VHostPath ,
31
+ kind = exchange ,
32
+ name = <<>>}).
33
+
30
34
% %----------------------------------------------------------------------------
31
35
32
36
-export_type ([key / 0 , deletions / 0 ]).
@@ -156,6 +160,14 @@ recover_semi_durable_route_txn(R = #route{binding = B}, X) ->
156
160
(Serial , false ) -> x_callback (Serial , X , add_binding , B )
157
161
end ).
158
162
163
+ exists (# binding {source = ? DEFAULT_EXCHANGE (_ ),
164
+ destination = # resource {kind = queue , name = QName } = Queue ,
165
+ key = QName ,
166
+ args = []}) ->
167
+ case rabbit_amqqueue :lookup (Queue ) of
168
+ {ok , _ } -> true ;
169
+ {error , not_found } -> false
170
+ end ;
159
171
exists (Binding ) ->
160
172
binding_action (
161
173
Binding , fun (_Src , _Dst , B ) ->
@@ -247,9 +259,7 @@ list(VHostPath) ->
247
259
[B || # route {binding = B } <- mnesia :dirty_match_object (rabbit_route ,
248
260
Route )].
249
261
250
- list_for_source (# resource {kind = exchange ,
251
- virtual_host = VHostPath ,
252
- name = <<>>}) ->
262
+ list_for_source (? DEFAULT_EXCHANGE (VHostPath )) ->
253
263
implicit_bindings (VHostPath );
254
264
list_for_source (SrcName ) ->
255
265
mnesia :async_dirty (
@@ -273,33 +283,30 @@ list_for_destination(DstName) ->
273
283
274
284
implicit_bindings (VHostPath ) ->
275
285
DstQueues = rabbit_amqqueue :list_names (VHostPath ),
276
- DefaultExchange = # resource {virtual_host = VHostPath ,
277
- kind = exchange ,
278
- name = <<>>},
279
- [ # binding {source = DefaultExchange ,
286
+ [ # binding {source = ? DEFAULT_EXCHANGE (VHostPath ),
280
287
destination = DstQueue ,
281
- key = QName }
288
+ key = QName ,
289
+ args = []}
282
290
|| DstQueue = # resource {name = QName } <- DstQueues ].
283
291
284
292
implicit_for_destination (DstQueue = # resource {kind = queue ,
285
293
virtual_host = VHostPath ,
286
294
name = QName }) ->
287
- DefaultExchange = # resource {virtual_host = VHostPath ,
288
- kind = exchange ,
289
- name = <<>>},
290
- [# binding {source = DefaultExchange ,
295
+ [# binding {source = ? DEFAULT_EXCHANGE (VHostPath ),
291
296
destination = DstQueue ,
292
- key = QName }];
297
+ key = QName ,
298
+ args = []}];
293
299
implicit_for_destination (_ ) ->
294
300
[].
295
301
296
- list_for_source_and_destination (# resource {kind = exchange ,
297
- virtual_host = VHostPath ,
298
- name = <<>>} = DefaultExchange ,
302
+ list_for_source_and_destination (? DEFAULT_EXCHANGE (VHostPath ),
299
303
# resource {kind = queue ,
300
304
virtual_host = VHostPath ,
301
305
name = QName } = DstQueue ) ->
302
- [# binding {source = DefaultExchange , destination = DstQueue , key = QName }];
306
+ [# binding {source = ? DEFAULT_EXCHANGE (VHostPath ),
307
+ destination = DstQueue ,
308
+ key = QName ,
309
+ args = []}];
303
310
list_for_source_and_destination (SrcName , DstName ) ->
304
311
mnesia :async_dirty (
305
312
fun () ->
0 commit comments