Handling Session Events
JCSMP
- Session Events
An application can register an implementation of the
SessionEventHandler
interface 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 aJCSMPReconnectEventHandler
instance when acquiring that consumer. This handler receives callbacks before and after the client’s TCP connection is reconnected after a connection failure.
Java RTO API
An application can register a SessionEventCallback
when creating a Session with ContextHandle.createSessionForHandle(...)
.
For high-performance implementations of the 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 Java RTO API Best Practices.
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+ Messaging API C reference.
.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+ Messaging API .NET reference.
JavaScript and Node.js APIs
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 JavaScript and Node.js API Reference.
Related Samples
- For an example of how to configure a Session event handler for JCSMP, see
SampleUtils.java
included with the sample files. - For an example of how to configure a Session event callback for the Java RTO API, see
SampleUtils.java
included with the sample files. - For an example of how to configure a Session event callback for the C API, see the
common.c
sample file. - For an example of how to configure a Session event delegate for the .NET API, see
SampleUtils.cs
included with the sample files. - For an example of how to configure Session event listeners for the JavaScript and Node.js APIs, see the
TopicSubscriber.js
sample.