Timeplus Messaging
A Python package for messaging with Timeplus streams. This library provides a simplified messaging interface on top of Timeplus, supporting message publishing and consumption patterns similar to traditional messaging systems.
Features
- Producer API: Easily send messages to Timeplus streams
- Consumer API: Consume messages from one or multiple Timeplus streams
- Topic-based messaging: Use Timeplus streams as message topics
- Message headers support: Include metadata with your messages
- Batch consumption: Efficiently poll for multiple messages
- Pause/resume capability: Control consumption flow
- Stream auto-creation: Automatically create streams as needed
- Callback-based processing: Register callbacks for specific topics
Installation
pip install timeplus-messaging
Requirements
- Python 3.7 or higher
- proton-driver (Timeplus client driver)
Quick Start
Producer Example
from timeplus_messaging import create_producer
# Create a producer
producer = create_producer(
host="your-timeplus-host",
port=8463,
user="default",
password="your-password",
database="default"
)
# Send a simple message
producer.send(
topic="my_topic",
value="Hello, Timeplus!",
key="greeting"
)
# Send a JSON message
producer.send(
topic="my_topic",
value={"message": "Hello, Timeplus!", "priority": "high"},
headers={"source": "application", "version": "1.0"}
)
# Close the producer
producer.close()
Single Topic Consumer Example - Kafka Style
from timeplus_messaging import create_consumer
# Create a single topic consumer
consumer = create_consumer(
topic="my_topic",
host="your-timeplus-host",
port=8463,
user="default",
password="your-password",
database="default",
auto_offset_reset="latest" # or "earliest"
)
# Poll for messages
records = consumer.poll(timeout_ms=5000)
for topic, messages in records.items():
for message in messages:
print(f"Received: {message.value} with key={message.key}")
# Use as iterator
for record in consumer:
print(f"Received: {record.value}")
# Break out of the loop after processing
break
# Close the consumer
consumer.close()
Multi-Topic Consumer Example - Queue Style
from timeplus_messaging import create_subscribe_consumer
# Create a multi-topic consumer
consumer = create_subscribe_consumer(
host="your-timeplus-host",
port=8463,
user="default",
password="your-password",
database="default",
auto_offset_reset="latest"
)
# Add a callback for a specific topic
def process_message(record):
print(f"Callback received: {record.value}")
# Subscribe to multiple topics
consumer.subscribe(["topic1", "topic2"], callback=process_message)
# wait all message to be consumed
time.sleep(10)
# Unsubscribe from topic
consumer.unsubscribe("topic2")
# Close the consumer
consumer.close()
Advanced Usage
Using Consumer Callbacks
from timeplus_messaging import create_subscribe_consumer
consumer = create_subscribe_consumer(
host="your-timeplus-host",
port=8463,
user="default",
password="your-password"
)
def process_logs(record):
print(f"Log received: {record.value}")
# Process log message
def process_metrics(record):
print(f"Metric received: {record.value}")
# Process metric data
# Subscribe with callbacks
consumer.subscribe("logs", callback=process_logs)
consumer.subscribe("metrics", callback=process_metrics)
License
MIT
Metadata
Release files for timeplus-messaging 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timeplus_messaging-0.0.3.tar.gz | 16.2 kB | Without provenance | Details for timeplus_messaging-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timeplus_messaging-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for timeplus_messaging-0.0.3-py3-none-any.whl |
Total release size: 30.0 kB
Release files / timeplus_messaging-0.0.3.tar.gz
| Download URL | timeplus_messaging-0.0.3.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9799507fc54a45510ed16094f3c6d738723e5c9f42e0fdeebb511601bce5f0ed
|
|
BLAKE2b-256 checksum How to use checksums |
8f2f8f1a59f29c6dee1050d9efc0034fb0863edee49a222b03f1d232644d12ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Release files / timeplus_messaging-0.0.3-py3-none-any.whl
| Download URL | timeplus_messaging-0.0.3-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e603467d7e692f8cd9152cddf36b38bd6fc00f0d446369401bb71b262cabcd14
|
|
BLAKE2b-256 checksum How to use checksums |
74fa1f170f900f8b3285d74f5c9c3265e5358571b78c15bd92a18dd6d2d22ca4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Security for timeplus-messaging 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.