stream-pymqi
High-level IBM MQ consumer and producer library for Python
Features
- Simple consumer/producer API for IBM MQ
- Automatic connection management and reconnection
- Stream-style message processing (async/await ready)
- Configuration via Python dict or YAML files
- Thread-safe operations
- Error handling and retry mechanisms
- Compatible with Python 3.8+
Installation
pip install stream-pymqi
Usage
Consumer
from stream_pymqi import Consumer, StreamConfig
config = StreamConfig(
host='localhost',
port=1414,
channel='CHANNEL1',
queue_manager='QM1',
queue_name='QUEUE1'
)
consumer = Consumer(config)
@consumer.on_message()
def handle_message(message):
print(f"Received: {message}")
consumer.start()
Producer
from stream_pymqi import Producer, StreamConfig, Message
config = StreamConfig(
host='localhost',
port=1414,
channel='CHANNEL1',
queue_manager='QM1',
queue_name='QUEUE1'
)
producer = Producer(config)
# Send a message
producer.send(Message(data=b"Hello, IBM MQ!"))
# Or send a string directly
producer.send_string("Hello, IBM MQ!")
producer.disconnect()
Configuration via YAML
from stream_pymqi import Consumer, StreamConfig
config = StreamConfig.from_yaml('config.yaml')
consumer = Consumer(config)
consumer.start()
Example config.yaml:
host: localhost
port: 1414
channel: CHANNEL1
queue_manager: QM1
queue_name: QUEUE1
ssl: false
auto_reconnect: true
With SSL
from stream_pymqi import Consumer, StreamConfig
config = StreamConfig(
host='localhost',
port=1414,
channel='CHANNEL1',
queue_manager='QM1',
queue_name='QUEUE1',
ssl=True,
ssl_cipher_spec='TLS_RSA_WITH_AES_128_CBC_SHA'
)
consumer = Consumer(config)
consumer.start()
Error Handling
from stream_pymqi import Consumer, StreamConfig
def on_error(exception):
print(f"Error: {exception}")
config = StreamConfig(
host='localhost',
port=1414,
channel='CHANNEL1',
queue_manager='QM1',
queue_name='QUEUE1',
on_error=on_error
)
consumer = Consumer(config)
consumer.start()
API Reference
StreamConfig
Configuration class for IBM MQ connection.
Parameters:
host: IBM MQ host addressport: IBM MQ port (default: 1414)channel: IBM MQ channel namequeue_manager: IBM MQ queue manager namequeue_name: IBM MQ queue nameuser: IBM MQ user (optional)password: IBM MQ password (optional)connect_retries: Number of connection retries (default: 3)connect_retry_interval: Interval between retries in seconds (default: 5)message_wait_interval: Wait interval for message consumption in seconds (default: 5)auto_reconnect: Enable automatic reconnection (default: True)max_message_size: Maximum message size in bytes (default: 1048576)ssl: Enable SSL connection (default: False)ssl_cipher_spec: SSL cipher specification (optional)cert_store_location: Certificate store location (optional)
Consumer
IBM MQ consumer with automatic connection management.
Methods:
on_message(): Decorator to register a message handlerregister_handler(handler): Register a message handlerstart(): Start consuming messages in a background threadstop(): Stop consuming messagesis_running(): Check if consumer is running
Producer
IBM MQ producer with automatic connection management.
Methods:
connect(): Establish connection to IBM MQdisconnect(): Disconnect from IBM MQsend(message): Send a message to the queuesend_string(text): Send a string messagesend_bytes(data): Send a bytes messageis_connected(): Check if connected to IBM MQ
License
Apache-2.0
Metadata
Release files for stream-pymqi 0.1.0
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 |
|---|---|---|---|---|
| stream_pymqi-0.1.0.tar.gz | 11.7 kB | Without provenance | Details for stream_pymqi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stream_pymqi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for stream_pymqi-0.1.0-py3-none-any.whl |
Total release size: 26.7 kB
Release files / stream_pymqi-0.1.0.tar.gz
| Download URL | stream_pymqi-0.1.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4cc526a151bcc0e6c0ab2b824ace227be80bc9f924b15c1be592dcce43577f08
|
|
BLAKE2b-256 checksum How to use checksums |
06f64d096ca0277266b09a484a0d7c8f4753f5b838e7d4961a8211b18da0f787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1015-azure
|
Release files / stream_pymqi-0.1.0-py3-none-any.whl
| Download URL | stream_pymqi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
682a8624ba17d0ba04f6a60ecf99c5e45b590bbe3873f832d075ac2876324590
|
|
BLAKE2b-256 checksum How to use checksums |
2a696956023c09c1999f9a809c34d093371c97e75f2922e0a2f9af81b40cc790
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1015-azure
|
Security for stream-pymqi 0.1.0
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.