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