Registry / communication / solace-pubsubplus

solace-pubsubplus

JSON →
library1.11.0pypypiunverified

The `solace-pubsubplus` library provides a Python API for interacting with Solace PubSub+ event brokers. It supports publishing and subscribing to messages, managing topics, queues, and handling various messaging patterns. Currently at version 1.11.0, it follows a regular release cadence with updates for new features and bug fixes, typically aligning with Solace PubSub+ broker releases.

pip install solace-pubsubplus
INSTALL
IMPORT
SIG · SOLACE-PUBSUBPLUS
S
solace-pubsubplus
communicationpythonv1.11.0
Install
1.8s avg
Import
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.11.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.8s · import 0.000s · 33MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SolaceSession
from solace_pubsubplus import SolaceSession
Message
from solace_pubsubplus import Message
Subscription
from solace_pubsubplus import Subscription
SolaceSessionProperties
from solace_pubsubplus import SolaceSessionProperties
DeliveryMode
from solace_pubsubplus import DeliveryMode

This quickstart demonstrates how to connect to a Solace PubSub+ broker, subscribe to a topic, publish a direct message, and receive messages using a callback function. Ensure `SOLACE_HOST`, `SOLACE_VPN`, `SOLACE_USERNAME`, and `SOLACE_PASSWORD` environment variables are set or updated in the script.

import os import time import threading from solace_pubsubplus import SolaceSession, SolaceSessionProperties, Message, MessageBuilder, DeliveryMode, Subscription, SubscribeFlags, SolaceLogLevel # Configuration from environment variables SOLACE_HOST = os.environ.get("SOLACE_HOST", "localhost:55555") # e.g., 'tcp://your_broker_host:55555' SOLACE_VPN = os.environ.get("SOLACE_VPN", "default") SOLACE_USERNAME = os.environ.get("SOLACE_USERNAME", "username") SOLACE_PASSWORD = os.environ.get("SOLACE_PASSWORD", "password") TOPIC_NAME = "python/quickstart/hello" # Global lock for thread-safe printing print_lock = threading.Lock() def on_message_received(message: Message): """Callback function for received messages.""" with print_lock: print(f"Received message on topic '{message.get_destination_as_topic()}'") if message.get_data(): print(f"Message data: {message.get_data().decode('utf-8')}") def run_quickstart(): # 1. Configure Solace Session Properties session_properties = SolaceSessionProperties() session_properties.host = SOLACE_HOST session_properties.vpn_name = SOLACE_VPN session_properties.username = SOLACE_USERNAME session_properties.password = SOLACE_PASSWORD session_properties.connect_retries = 3 session_properties.reconnect_retries = 3 # Set log level for more detailed output (optional) SolaceSession.set_log_level(SolaceLogLevel.INFO) session = None try: # 2. Create and Connect the Solace Session session = SolaceSession(session_properties) session.connect() with print_lock: print(f"Connected to Solace PubSub+ broker at {SOLACE_HOST}") # 3. Set up Message Callback session.set_message_receive_callback(on_message_received) # 4. Subscribe to a Topic subscription = Subscription(TOPIC_NAME) session.subscribe(subscription, SubscribeFlags.WAIT_FOR_CONFIRM) with print_lock: print(f"Subscribed to topic '{TOPIC_NAME}'") # 5. Publish a Message message_builder = MessageBuilder() message = message_builder \ .with_delivery_mode(DeliveryMode.DIRECT) \ .with_topic(TOPIC_NAME) \ .with_property("user-property", "value") \ .build() message.set_data(f"Hello from Python Quickstart! Timestamp: {time.time()}".encode('utf-8')) session.publish(message) with print_lock: print(f"Published message to topic '{TOPIC_NAME}'") # 6. Wait briefly for the message to be received (if publishing to self) time.sleep(2) except Exception as e: with print_lock: print(f"An error occurred: {e}") finally: if session: # 7. Disconnect the Session with print_lock: print("Disconnecting Solace Session...") session.disconnect() with print_lock: print("Disconnected.") if __name__ == "__main__": run_quickstart()
Debug
Known issues
gotchaThe SolaceSession object is generally not thread-safe. Interactions with the session (connect, disconnect, publish, subscribe, etc.) should be performed from a single thread or carefully synchronized to avoid race conditions and undefined behavior.
fix
Access the `SolaceSession` instance from a dedicated thread or use appropriate threading primitives (e.g., locks) if multiple threads need to interact with it.
affects: All versions
gotchaMessage receive callbacks execute on an internal client thread. Blocking operations within these callbacks can prevent other messages from being processed or halt the client's internal event loop, leading to performance issues or deadlocks.
fix
Keep message callbacks short and non-blocking. If significant processing is required, dispatch the message to a separate worker thread or queue for asynchronous handling.
affects: All versions
gotchaIt's crucial to explicitly manage the `DeliveryMode` for messages. `DeliveryMode.DIRECT` offers high performance but no guaranteed delivery, while `DeliveryMode.PERSISTENT` ensures guaranteed delivery but with higher overhead. The default might be `DIRECT`.
fix
Always explicitly set `DeliveryMode` using `MessageBuilder.with_delivery_mode()` based on your application's reliability requirements.
affects: All versions
gotchaForgetting to call `session.disconnect()` can leave open connections, consume broker resources, and prevent the client from gracefully cleaning up.
fix
Always ensure `session.disconnect()` is called, typically within a `finally` block, to release resources and inform the broker of client departure.
affects: All versions
Upgrade
Version history
1.11.0latest on PyPI · released Dec 5, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources