1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -37,7 +37,12 @@ private BindingBuilder() {
37
37
}
38
38
39
39
public static DestinationConfigurer bind (Queue queue ) {
40
- return new DestinationConfigurer (queue .getName (), DestinationType .QUEUE );
40
+ if ("" .equals (queue .getName ())) {
41
+ return new DestinationConfigurer (queue , DestinationType .QUEUE );
42
+ }
43
+ else {
44
+ return new DestinationConfigurer (queue .getName (), DestinationType .QUEUE );
45
+ }
41
46
}
42
47
43
48
public static DestinationConfigurer bind (Exchange exchange ) {
@@ -61,13 +66,22 @@ public static final class DestinationConfigurer {
61
66
62
67
protected final DestinationType type ; // NOSONAR
63
68
69
+ protected final Queue queue ; // NOSONAR
70
+
64
71
DestinationConfigurer (String name , DestinationType type ) {
72
+ this .queue = null ;
65
73
this .name = name ;
66
74
this .type = type ;
67
75
}
68
76
77
+ DestinationConfigurer (Queue queue , DestinationType type ) {
78
+ this .queue = queue ;
79
+ this .name = null ;
80
+ this .type = type ;
81
+ }
82
+
69
83
public Binding to (FanoutExchange exchange ) {
70
- return new Binding (this .name , this .type , exchange .getName (), "" , new HashMap <String , Object >());
84
+ return new Binding (this .queue , this . name , this .type , exchange .getName (), "" , new HashMap <String , Object >());
71
85
}
72
86
73
87
public HeadersExchangeMapConfigurer to (HeadersExchange exchange ) {
@@ -134,15 +148,17 @@ public final class HeadersExchangeSingleValueBindingCreator {
134
148
}
135
149
136
150
public Binding exists () {
137
- return new Binding (HeadersExchangeMapConfigurer .this .destination .name ,
151
+ return new Binding (HeadersExchangeMapConfigurer .this .destination .queue ,
152
+ HeadersExchangeMapConfigurer .this .destination .name ,
138
153
HeadersExchangeMapConfigurer .this .destination .type ,
139
154
HeadersExchangeMapConfigurer .this .exchange .getName (), "" , createMapForKeys (this .key ));
140
155
}
141
156
142
157
public Binding matches (Object value ) {
143
158
Map <String , Object > map = new HashMap <String , Object >();
144
159
map .put (this .key , value );
145
- return new Binding (HeadersExchangeMapConfigurer .this .destination .name ,
160
+ return new Binding (HeadersExchangeMapConfigurer .this .destination .queue ,
161
+ HeadersExchangeMapConfigurer .this .destination .name ,
146
162
HeadersExchangeMapConfigurer .this .destination .type ,
147
163
HeadersExchangeMapConfigurer .this .exchange .getName (), "" , map );
148
164
}
@@ -162,7 +178,8 @@ public final class HeadersExchangeKeysBindingCreator {
162
178
}
163
179
164
180
public Binding exist () {
165
- return new Binding (HeadersExchangeMapConfigurer .this .destination .name ,
181
+ return new Binding (HeadersExchangeMapConfigurer .this .destination .queue ,
182
+ HeadersExchangeMapConfigurer .this .destination .name ,
166
183
HeadersExchangeMapConfigurer .this .destination .type ,
167
184
HeadersExchangeMapConfigurer .this .exchange .getName (), "" , this .headerMap );
168
185
}
@@ -182,7 +199,8 @@ public final class HeadersExchangeMapBindingCreator {
182
199
}
183
200
184
201
public Binding match () {
185
- return new Binding (HeadersExchangeMapConfigurer .this .destination .name ,
202
+ return new Binding (HeadersExchangeMapConfigurer .this .destination .queue ,
203
+ HeadersExchangeMapConfigurer .this .destination .name ,
186
204
HeadersExchangeMapConfigurer .this .destination .type ,
187
205
HeadersExchangeMapConfigurer .this .exchange .getName (), "" , this .headerMap );
188
206
}
@@ -211,13 +229,13 @@ public static final class TopicExchangeRoutingKeyConfigurer extends AbstractRout
211
229
}
212
230
213
231
public Binding with (String routingKey ) {
214
- return new Binding (destination .name , destination .type , exchange , routingKey ,
232
+ return new Binding (destination .queue , destination . name , destination .type , exchange , routingKey ,
215
233
Collections .<String , Object >emptyMap ());
216
234
}
217
235
218
236
public Binding with (Enum <?> routingKeyEnum ) {
219
- return new Binding (destination .name , destination .type , exchange , routingKeyEnum . toString () ,
220
- Collections .<String , Object >emptyMap ());
237
+ return new Binding (destination .queue , destination . name , destination .type , exchange ,
238
+ routingKeyEnum . toString (), Collections .<String , Object >emptyMap ());
221
239
}
222
240
}
223
241
@@ -255,12 +273,14 @@ public GenericArgumentsConfigurer(GenericExchangeRoutingKeyConfigurer configurer
255
273
}
256
274
257
275
public Binding and (Map <String , Object > map ) {
258
- return new Binding (this .configurer .destination .name , this .configurer .destination .type , this .configurer .exchange ,
276
+ return new Binding (this .configurer .destination .queue ,
277
+ this .configurer .destination .name , this .configurer .destination .type , this .configurer .exchange ,
259
278
this .routingKey , map );
260
279
}
261
280
262
281
public Binding noargs () {
263
- return new Binding (this .configurer .destination .name , this .configurer .destination .type , this .configurer .exchange ,
282
+ return new Binding (this .configurer .destination .queue ,
283
+ this .configurer .destination .name , this .configurer .destination .type , this .configurer .exchange ,
264
284
this .routingKey , Collections .<String , Object >emptyMap ());
265
285
}
266
286
@@ -276,19 +296,20 @@ public static final class DirectExchangeRoutingKeyConfigurer extends AbstractRou
276
296
}
277
297
278
298
public Binding with (String routingKey ) {
279
- return new Binding (destination .name , destination .type , exchange , routingKey ,
299
+ return new Binding (destination .queue , destination . name , destination .type , exchange , routingKey ,
280
300
Collections .<String , Object >emptyMap ());
281
301
}
282
302
283
303
public Binding with (Enum <?> routingKeyEnum ) {
284
- return new Binding (destination .name , destination .type , exchange , routingKeyEnum . toString () ,
285
- Collections .<String , Object >emptyMap ());
304
+ return new Binding (destination .queue , destination . name , destination .type , exchange ,
305
+ routingKeyEnum . toString (), Collections .<String , Object >emptyMap ());
286
306
}
287
307
288
308
public Binding withQueueName () {
289
- return new Binding (destination .name , destination .type , exchange , destination .name ,
309
+ return new Binding (destination .queue , destination . name , destination .type , exchange , destination .name ,
290
310
Collections .<String , Object >emptyMap ());
291
311
}
312
+
292
313
}
293
314
294
315
}
0 commit comments