3131import io .netty .channel .EventLoop ;
3232import org .apache .activemq .artemis .cli .commands .ActionContext ;
3333import org .apache .activemq .artemis .cli .commands .messages .ConnectionProtocol ;
34+ import org .apache .activemq .artemis .cli .factory .ConnectionFactoryClosable ;
3435import org .apache .activemq .artemis .jms .client .ActiveMQDestination ;
3536import picocli .CommandLine .Command ;
3637import picocli .CommandLine .Option ;
@@ -98,7 +99,6 @@ public class PerfClientCommand extends PerfCommand {
9899 protected void onExecuteBenchmark (final ConnectionFactory producerConnectionFactory , final Destination [] jmsDestinations , final ActionContext context ) throws Exception {
99100 final ConnectionProtocol listenerProtocol = Objects .requireNonNullElse (this .consumerProtocol , protocol );
100101 final String listenerUrl = Objects .requireNonNullElse (this .consumerUrl , brokerURL );
101- final ConnectionFactory consumerConnectionFactory = createConnectionFactory (listenerUrl , user , password , null , listenerProtocol );
102102 if (consumerConnections == 0 ) {
103103 if (sharedSubscription > 0 ) {
104104 if (getClientID () == null ) {
@@ -122,17 +122,18 @@ protected void onExecuteBenchmark(final ConnectionFactory producerConnectionFact
122122 boolean warmingUp = warmup != 0 ;
123123 final LiveStatistics statistics ;
124124 final StringBuilder skratchBuffer = new StringBuilder ();
125- try (MessageListenerBenchmark consumerBenchmark = new MessageListenerBenchmarkBuilder ()
126- .setClientID (getClientID ())
127- .setDestinations (consumerProtocol != null ? lookupDestinations (consumerConnectionFactory ) : jmsDestinations )
128- .setFactory (consumerConnectionFactory )
129- .setTransacted (transaction )
130- .setConsumers (consumersPerDestination )
131- .setConnections (consumerConnections )
132- .setTimeProvider (() -> TimeUnit .NANOSECONDS .toMicros (System .nanoTime ()))
133- .setCanDelayMessageCount (true )
134- .setSharedSubscription (sharedSubscription )
135- .setDurableSubscription (durableSubscription )
125+ try (ConnectionFactoryClosable consumerConnectionFactory = createConnectionFactory (listenerUrl , user , password , null , listenerProtocol );
126+ MessageListenerBenchmark consumerBenchmark = new MessageListenerBenchmarkBuilder ()
127+ .setClientID (getClientID ())
128+ .setDestinations (consumerProtocol != null ? lookupDestinations (consumerConnectionFactory ) : jmsDestinations )
129+ .setFactory (consumerConnectionFactory )
130+ .setTransacted (transaction )
131+ .setConsumers (consumersPerDestination )
132+ .setConnections (consumerConnections )
133+ .setTimeProvider (() -> TimeUnit .NANOSECONDS .toMicros (System .nanoTime ()))
134+ .setCanDelayMessageCount (true )
135+ .setSharedSubscription (sharedSubscription )
136+ .setDurableSubscription (durableSubscription )
136137 .createMessageListenerBenchmark ()) {
137138
138139 final DefaultEventLoopGroup eventLoopGroup = new DefaultEventLoopGroup (threads ) {
0 commit comments