1
- // Copyright (c) 2020-2021 VMware, Inc. or its affiliates. All rights reserved.
1
+ // Copyright (c) 2020-2022 VMware, Inc. or its affiliates. All rights reserved.
2
2
//
3
3
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
4
4
// Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL").
34
34
import com .rabbitmq .stream .impl .OffsetTrackingCoordinator .Registration ;
35
35
import com .rabbitmq .stream .impl .StreamConsumerBuilder .TrackingConfiguration ;
36
36
import com .rabbitmq .stream .impl .StreamEnvironmentBuilder .DefaultTlsConfiguration ;
37
+ import com .rabbitmq .stream .impl .Utils .ClientConnectionType ;
37
38
import io .netty .buffer .ByteBufAllocator ;
38
39
import io .netty .channel .EventLoopGroup ;
39
40
import io .netty .channel .nio .NioEventLoopGroup ;
@@ -102,7 +103,8 @@ class StreamEnvironment implements Environment {
102
103
int maxConsumersByConnection ,
103
104
DefaultTlsConfiguration tlsConfiguration ,
104
105
ByteBufAllocator byteBufAllocator ,
105
- boolean lazyInit ) {
106
+ boolean lazyInit ,
107
+ Function <ClientConnectionType , String > connectionNamingStrategy ) {
106
108
this (
107
109
scheduledExecutorService ,
108
110
clientParametersPrototype ,
@@ -116,6 +118,7 @@ class StreamEnvironment implements Environment {
116
118
tlsConfiguration ,
117
119
byteBufAllocator ,
118
120
lazyInit ,
121
+ connectionNamingStrategy ,
119
122
cp -> new Client (cp ));
120
123
}
121
124
@@ -132,6 +135,7 @@ class StreamEnvironment implements Environment {
132
135
DefaultTlsConfiguration tlsConfiguration ,
133
136
ByteBufAllocator byteBufAllocator ,
134
137
boolean lazyInit ,
138
+ Function <ClientConnectionType , String > connectionNamingStrategy ,
135
139
Function <Client .ClientParameters , Client > clientFactory ) {
136
140
this .recoveryBackOffDelayPolicy = recoveryBackOffDelayPolicy ;
137
141
this .topologyUpdateBackOffDelayPolicy = topologyBackOffDelayPolicy ;
@@ -202,10 +206,14 @@ class StreamEnvironment implements Environment {
202
206
this ,
203
207
maxProducersByConnection ,
204
208
maxTrackingConsumersByConnection ,
209
+ connectionNamingStrategy ,
205
210
Utils .coordinatorClientFactory (this ));
206
211
this .consumersCoordinator =
207
212
new ConsumersCoordinator (
208
- this , maxConsumersByConnection , Utils .coordinatorClientFactory (this ));
213
+ this ,
214
+ maxConsumersByConnection ,
215
+ connectionNamingStrategy ,
216
+ Utils .coordinatorClientFactory (this ));
209
217
this .offsetTrackingCoordinator = new OffsetTrackingCoordinator (this );
210
218
211
219
AtomicReference <Client .ShutdownListener > shutdownListenerReference = new AtomicReference <>();
@@ -231,7 +239,10 @@ class StreamEnvironment implements Environment {
231
239
newLocatorParameters
232
240
.host (address .host ())
233
241
.port (address .port ())
234
- .clientProperty ("connection_name" , "rabbitmq-stream-locator" ));
242
+ .clientProperty (
243
+ "connection_name" ,
244
+ connectionNamingStrategy .apply (
245
+ ClientConnectionType .LOCATOR )));
235
246
LOGGER .debug ("Locator connected on {}" , address );
236
247
return newLocator ;
237
248
})
@@ -254,7 +265,9 @@ class StreamEnvironment implements Environment {
254
265
.duplicate ()
255
266
.host (address .host ())
256
267
.port (address .port ())
257
- .clientProperty ("connection_name" , "rabbitmq-stream-locator" )
268
+ .clientProperty (
269
+ "connection_name" ,
270
+ connectionNamingStrategy .apply (ClientConnectionType .LOCATOR ))
258
271
.shutdownListener (shutdownListenerReference .get ());
259
272
try {
260
273
this .locator = clientFactory .apply (locatorParameters );
0 commit comments