Handling Session Events
Session events provide information about the state of a client connection to the event broker, including connection establishment, disconnection, and error conditions. Properly handling these events allows your application to respond appropriately to changes in connection status and maintain robust messaging operations.
PubSub+ Java RTO API
An application can register a SessionEventCallback
when creating a session with ContextHandle.createSessionForHandle(...)
.
For high-performance implementations of the PubSub+ Java RTO API, applications should use SessionHandle.getSessionEvent(...)
rather than SessionHandle.takeSessionEvent(...)
. When a get is used, the API retains responsibility for the event and will destroy it at the appropriate time. When a take is used, the API gives up control of the event and it is up to the application to destroy it.
For more information on using getSessionEvent()
and takeSessionEvent()
, see Get vs. Take in PubSub+ Java RTO API Best Practices.
PubSub+ C API
When a session is created, the application must provide a session event callback (solClient_session_eventCallbackInfoFunc_t
), along with an optional pointer to client data. This callback routine is invoked for event broker events that occur for the session, such as connection problems, or publish or subscription issues.
For a complete list of possible session events,see the PubSub+ C API reference.
PubSub+ .NET API
When a session is created, the application must provide a session event delegate (EventHandler<SessionEventArgs>
) that is invoked each time an event occurs over the session.
For a complete list of session events, see the PubSub+ .NET API reference.
PubSub+ Messaging API for JavaScript and Node.js
When a session is created, the application must provide session event listeners for each important session events that are invoked each time an event occurs over the session.
For a complete list of session events, see solace.SessionEventCode
in the PubSub+ JavaScript API and PubSub+ Node.js API reference.
Related Samples
- For an example of how to configure a session event callback for the PubSub+ Java RTO API, see
SampleUtils.java
included with the sample files. - For an example of how to configure a session event callback for the PubSub+ C API, see the
common.c
sample file. - For an example of how to configure a session event delegate for the PubSub+ .NET API, see
SampleUtils.cs
included with the sample files. - For an example of how to configure session event listeners for the PubSub+ JavaScript API and PubSub+ Node.js API, see the
TopicSubscriber.js
sample.