High-level IBM MQ consumer and producer library for Python
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stream_pymqi-0.1.0.tar.gz.
File metadata
- Download URL: stream_pymqi-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cc526a151bcc0e6c0ab2b824ace227be80bc9f924b15c1be592dcce43577f08
|
|
| MD5 |
34e331f2ee395579d2e0bac4bc43e33f
|
|
| BLAKE2b-256 |
06f64d096ca0277266b09a484a0d7c8f4753f5b838e7d4961a8211b18da0f787
|
File details
Details for the file stream_pymqi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stream_pymqi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
682a8624ba17d0ba04f6a60ecf99c5e45b590bbe3873f832d075ac2876324590
|
|
| MD5 |
77d5be48c515797bcc6f4b8630fd8320
|
|
| BLAKE2b-256 |
2a696956023c09c1999f9a809c34d093371c97e75f2922e0a2f9af81b40cc790
|