Skip to content

Commit 20f1fb6

Browse files
author
Daniil Fedotov
committed
Connection name parameter to create connections
1 parent 52c7b1c commit 20f1fb6

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,11 @@ protected FrameHandlerFactory createFrameHandlerFactory() throws IOException {
644644
* @throws IOException if it encounters a problem
645645
*/
646646
public Connection newConnection(Address[] addrs) throws IOException, TimeoutException {
647-
return newConnection(this.sharedExecutor, Arrays.asList(addrs));
647+
return newConnection(this.sharedExecutor, Arrays.asList(addrs), null);
648+
}
649+
650+
public Connection newConnection(Address[] addrs, String connectionName) throws IOException, TimeoutException {
651+
return newConnection(this.sharedExecutor, Arrays.asList(addrs), connectionName);
648652
}
649653

650654
/**
@@ -660,7 +664,11 @@ public Connection newConnection(Address[] addrs) throws IOException, TimeoutExce
660664
* @throws IOException if it encounters a problem
661665
*/
662666
public Connection newConnection(List<Address> addrs) throws IOException, TimeoutException {
663-
return newConnection(this.sharedExecutor, addrs);
667+
return newConnection(this.sharedExecutor, addrs, null);
668+
}
669+
670+
public Connection newConnection(List<Address> addrs, String connectionName) throws IOException, TimeoutException {
671+
return newConnection(this.sharedExecutor, addrs, connectionName);
664672
}
665673

666674
/**
@@ -678,7 +686,11 @@ public Connection newConnection(List<Address> addrs) throws IOException, Timeout
678686
* @see <a href="http://www.rabbitmq.com/api-guide.html#recovery">Automatic Recovery</a>
679687
*/
680688
public Connection newConnection(ExecutorService executor, Address[] addrs) throws IOException, TimeoutException {
681-
return newConnection(executor, Arrays.asList(addrs));
689+
return newConnection(executor, Arrays.asList(addrs), null);
690+
}
691+
692+
public Connection newConnection(ExecutorService executor, Address[] addrs, String connectionName) throws IOException, TimeoutException {
693+
return newConnection(executor, Arrays.asList(addrs), connectionName);
682694
}
683695

684696
/**
@@ -695,11 +707,16 @@ public Connection newConnection(ExecutorService executor, Address[] addrs) throw
695707
* @throws java.io.IOException if it encounters a problem
696708
* @see <a href="http://www.rabbitmq.com/api-guide.html#recovery">Automatic Recovery</a>
697709
*/
698-
public Connection newConnection(ExecutorService executor, List<Address> addrs)
710+
public Connection newConnection(ExecutorService executor, List<Address> addrs, String connectionName)
699711
throws IOException, TimeoutException {
700712
// make sure we respect the provided thread factory
701713
FrameHandlerFactory fhFactory = createFrameHandlerFactory();
702714
ConnectionParams params = params(executor);
715+
if (connectionName != null) {
716+
Map<String, Object> properties = params.getClientProperties().clone();
717+
properties.put("connection_name", connectionName);
718+
params.setClientProperties(properties);
719+
}
703720

704721
if (isAutomaticRecoveryEnabled()) {
705722
// see com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory#newConnection

0 commit comments

Comments
 (0)