Handling Session Events in the Solace JCSMP API
In the Solace JCSMP API, session events and channel reconnect events provide insights into the state of the connection between a client application and the Solace event broker. These events enable you to monitor connection health, detect disruptions, and handle reconnection logic in your applications.
- Session Events
An application can register an implementation of the
SessionEventHandlerinterface when creating a Session throughJCSMPFactory#createSession(JCSMPProperties, Context, SessionEventHandler). This handler receives callbacks for Session events defined inSessionEvent. - Channel Reconnect Events
An application that uses the Session’s default message consumer (acquired through
JCSMPSession#getMessageConsumer()), can register aJCSMPReconnectEventHandlerinstance when acquiring that consumer. This handler receives callbacks before and after the client’s TCP connection is reconnected after a connection failure.
For an example of how to configure a session event handler for JCSMP, see SampleUtils.java in the Solace Developer Hub.