Spring-cloud-stream Solace connectivity issue

263 Views Asked by At

In one of my Java-Spring boot based micro-service, i have the Solace integration setup for messaging. I am using the spring-cloud-stream and Solace binder to connect the Solace.

Overall the integration works well, however whenever i am rebooting the Solace server, the spring-boot service is not able to make a connection to Solace. Even after retrying 10 times its not able to establish the connection. Then i have to manually start the spring-boot service and then the connection reestablish.

Is there any configuration i can use to have to force reconnect between spring-cloud-stream and Solace.

Thanks Anuj

1

There are 1 best solutions below

0
Mrc0113 On

I test this locally using the sample app here and it worked fine. App was connected. Turned off broker. Turned broker back on. App reconnected. https://github.com/SolaceSamples/solace-samples-spring/tree/master/cloud-stream-sink

You can configure your connect and reconnect retries using connectRetries, reconnectRetries, etc prefixed by solace.java or spring.cloud.stream.binders.<binder-name>.environment.solace.java. But by default reconnectRetries is set to -1 which should retry forever. Can you make sure you don't have them set to something else?

While the broker service isn't available you should see the app logging something like this:

2023-09-11T12:12:00.595-04:00  INFO 61853 --- [connect_service] c.s.j.protocol.impl.TcpClientChannel     : Client-1: Connecting to host 'orig=tcp://localhost:55554, scheme=tcp://, host=localhost, port=55554' (host 1 of 1, smfclient 1, attempt 1 of 2147483647, this_host_attempt: 8 of 21)
2023-09-11T12:12:00.604-04:00  INFO 61853 --- [connect_service] c.s.j.protocol.impl.TcpClientChannel     : Client-1: Connection attempt failed to host 'localhost' ReconnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: marc.localdomain/61853/00210001/vUDlQD7-FL   Local addr: 127.0.0.1 Local port: 52443   Remote addr: localhost  Remote port: 55554) - Error communicating with the router. cause: java.io.IOException: Unable to read enough bytes from stream!

And then when it reconnected I saw this:

2023-09-11T12:12:21.715-04:00  INFO 61853 --- [connect_service] c.s.j.protocol.impl.TcpClientChannel     : Client-1: Connecting to host 'orig=tcp://localhost:55554, scheme=tcp://, host=localhost, port=55554' (host 1 of 1, smfclient 1, attempt 1 of 2147483647, this_host_attempt: 15 of 21)
2023-09-11T12:12:21.728-04:00  INFO 61853 --- [connect_service] c.s.j.protocol.impl.TcpClientChannel     : Client-1: Connected to host 'orig=tcp://localhost:55554, scheme=tcp://, host=localhost, port=55554' (smfclient 1)