javasolace

Solace keeps instantiating new TcpClientChannel


I wrote 25 csv files (each with about 1000+ entries) to solace. When I start replaying all the messages available in queue and publishing the messages, after a while, I get an error like this:

Client-17280: Connecting to host 'orig=tcp://vklnld2983:55555, scheme=tcp://, host=vklnld2983, port=55555' (host 1 of 1, smfclient 17280, attempt 1 of 1, this_host_attempt: 1 of 1) 
Client-17281: Connecting to host 'orig=tcp://vklnld2983:55555, scheme=tcp://, host=vklnld2983, port=55555' (host 1 of 1, smfclient 17281, attempt 1 of 1, this_host_attempt: 1 of 1)
Client-17282: Connecting to host 'orig=tcp://vklnld2983:55555, scheme=tcp://, host=vklnld2983, port=55555' (host 1 of 1, smfclient 17282, attempt 1 of 1, this_host_attempt: 1 of 1)
Client-17280: Connection attempt failed to host 'vklnld2983' ConnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: HKGITDW137306/29042/87494380/kMGp65FuY3   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router. cause: java.net.ConnectException: Connection refused ((Client name: HKGITDW137306/29042/87494380/kMGp65FuY3   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - )
Client-17281: Connection attempt failed to host 'vklnld2983' ConnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: HKGITDW137306/29042/874a4381/TExAJ1qMsJ   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router. cause: java.net.ConnectException: Connection refused ((Client name: HKGITDW137306/29042/874a4381/TExAJ1qMsJ   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - )
Client-17282: Connection attempt failed to host 'vklnld2983' ConnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: HKGITDW137306/29042/874b4382/GViVP_ZJ_v   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router. cause: java.net.ConnectException: Connection refused ((Client name: HKGITDW137306/29042/874b4382/GViVP_ZJ_v   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - )
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Error creating connection - transport error ((Client name: HKGITDW137306/29042/874a4381/TExAJ1qMsJ   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router.)
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:311) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:185) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:507) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:661) ~[spring-jms-5.3.24.jar:5.3.24]
    at com.clsa.aperture.service.inventory.InventoryService.lambda$onEvents$13(InventoryService.java:281) ~[classes/:?]
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850) ~[?:?]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
    at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290) ~[?:?]
    at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
Caused by: javax.jms.JMSException: Error creating connection - transport error ((Client name: HKGITDW137306/29042/874a4381/TExAJ1qMsJ   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router.)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
    at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
    at com.solacesystems.jms.impl.JMSExceptionValue.newInstance(JMSExceptionValue.java:36) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.impl.JCSMPExceptionMapper$ArrayListMapper.get(JCSMPExceptionMapper.java:32) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.impl.JCSMPExceptionMapper.get(JCSMPExceptionMapper.java:95) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.impl.Validator.createJMSException(Validator.java:587) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:186) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:97) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnectionFactoryImpl.createConnection(SolConnectionFactoryImpl.java:114) ~[sol-jms-10.17.0.jar:?]
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:196) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:494) ~[spring-jms-5.3.24.jar:5.3.24]
    ... 13 more
Caused by: com.solacesystems.jcsmp.JCSMPTransportException: (Client name: HKGITDW137306/29042/874a4381/TExAJ1qMsJ   Local port: -1   Remote addr: vklnld2983  Remote port: 55555) - Error communicating with the router.
    at com.solacesystems.jcsmp.protocol.impl.TcpChannel.executePostOnce(TcpChannel.java:254) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.ChannelOpStrategyClient.performOpen(ChannelOpStrategyClient.java:101) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.performOpenSingle(TcpClientChannel.java:428) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.access$800(TcpClientChannel.java:124) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel$ClientChannelConnect.call(TcpClientChannel.java:2609) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.open(TcpClientChannel.java:404) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.impl.JCSMPBasicSession.sniffRouter(JCSMPBasicSession.java:422) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.impl.JCSMPBasicSession.connect(JCSMPBasicSession.java:1309) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:167) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:97) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnectionFactoryImpl.createConnection(SolConnectionFactoryImpl.java:114) ~[sol-jms-10.17.0.jar:?]
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:196) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:494) ~[spring-jms-5.3.24.jar:5.3.24]
    ... 13 more
Caused by: java.net.ConnectException: Connection refused
    at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]
    at sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]
    at sun.nio.ch.SocketChannelImpl.finishTimedConnect(SocketChannelImpl.java:1148) ~[?:?]
    at sun.nio.ch.SocketChannelImpl.blockingConnect(SocketChannelImpl.java:1183) ~[?:?]
    at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:98) ~[?:?]
    at com.solacesystems.jcsmp.protocol.smf.SimpleSmfClient.open(SimpleSmfClient.java:905) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.smf.SimpleSmfClient.doPostNoResponse(SimpleSmfClient.java:318) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.smf.SimpleSmfClient.doPost(SimpleSmfClient.java:235) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpChannel.executePostOnce(TcpChannel.java:199) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.ChannelOpStrategyClient.performOpen(ChannelOpStrategyClient.java:101) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.performOpenSingle(TcpClientChannel.java:428) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.access$800(TcpClientChannel.java:124) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel$ClientChannelConnect.call(TcpClientChannel.java:2609) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.open(TcpClientChannel.java:404) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.impl.JCSMPBasicSession.sniffRouter(JCSMPBasicSession.java:422) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jcsmp.impl.JCSMPBasicSession.connect(JCSMPBasicSession.java:1309) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:167) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnection.<init>(SolConnection.java:97) ~[sol-jms-10.17.0.jar:?]
    at com.solacesystems.jms.SolConnectionFactoryImpl.createConnection(SolConnectionFactoryImpl.java:114) ~[sol-jms-10.17.0.jar:?]
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:196) ~[spring-jms-5.3.24.jar:5.3.24]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:494) ~[spring-jms-5.3.24.jar:5.3.24]
    ... 13 more

Looking at the logs/stacktrace, it seems as if my application is making a lot of connects/disconnects, but I m not sure if I am exhausting some sort of connection pool, or solace views this action as "spammy" and refuses connection from my localhost. How do I reuse the TcpClientChannels instead of instantiating new connections on each attempt to connect?


Solution

  • Are you using a CachingConnectionFactory? You want to make sure you aren't creating and tearing down a connection and everything that goes with it for every message.

    Example using Spring Boot: https://tutorials.solace.dev/spring/spring-boot-autoconfigure/#SpringBootSenderjava