Contexts

The messaging APIs use processing Contexts for organizing communication between an application and a Solace PubSub+ event broker. Contexts act as containers in which Sessions are created and Session-related events can be handled.

A Context encapsulates threads that drive network I/O and message delivery notification for the Sessions and Session components associated with that Context. For JCSMP, one thread is used for I/O and another for notification. For the Java RTO, C, and .NET APIs, a single thread is used for both I/O and for notification. The life cycle of a Context‑owned thread is bound to the life cycle of the Context. The Javascript and Node.js APIs are single threaded and have a single global context that is not exposed.

Typically, a Context initializes and manages its own threads and file descriptors. However, the C API also allows client applications to drive the Context’s main loop with their own application-thread. For more information, refer to C API Best Practices.

Context APIs

PubSub+ Messaging API Call or Property

JCSMP

com.solacesystems.jcsmp.Context

Java RTO

com.solacesystems.solclientj.core.handle.ContextHandle

C

solClient_context_create(...)

solClient_opaqueContext_pt

.NET

SolaceSystems.Solclient.Messaging.ContextFactory

SolaceSystems.Solclient.Messaging.IContext

JavaScript and Node.js

Not applicable

The figure below shows the basic relationship between a Context and its dependent processing components.

Overview of Core Concepts