MQ Consumer
Project description
Amos
AmosMsg is a MQ consumer
1. MQ Consumer
your code
import json
from AmosMsg.AmosMsg import AmosMsg
def call_back(ch, method, properties, body):
message = json.loads(body.decode())
print(message)
ch.basic_ack(delivery_tag=method.delivery_tag)
print("%r" % body)
if __name__ == '__main__':
amos = AmosMsg(
msg_user='consumer_user',
msg_pass='consumer_password',
enable_ssl=False, # disable SSL
host="your.rabbitmq.host",
port=5672, # MQ default port is 5672
v_host="your_virtual_host",
exchange="your_exchange",
queue="your_queue",
)
amos.create_channel()
amos.create_queue()
amos.connect_exchange()
amos.run_consumer(call_back)
2. Use SSL
your code
import json
from AmosMsg.AmosMsg import AmosMsg
def call_back(ch, method, properties, body):
message = json.loads(body.decode())
print(message)
ch.basic_ack(delivery_tag=method.delivery_tag)
print("%r" % body)
if __name__ == '__main__':
amos = AmosMsg(
msg_user='consumer_user',
msg_pass='consumer_password',
enable_ssl=True, # enable SSL
host="your.rabbitmq.host",
port=5671, # MQ SSL default port is 5671
v_host="your_virtual_host",
exchange="your_exchange",
queue="your_queue",
ca="your/path/to/ca",
crt="your/path/to/crt",
key="your/path/to//key"
)
amos.create_channel()
amos.create_queue()
amos.connect_exchange()
amos.run_consumer(call_back)
3. Use config file
your code
import json
from AmosMsg.AmosMsg import AmosMsg
def call_back(ch, method, properties, body):
message = json.loads(body.decode())
print(message)
ch.basic_ack(delivery_tag=method.delivery_tag)
print("%r" % body)
if __name__ == '__main__':
amos = AmosMsg(
msg_user='consumer_user',
msg_pass='consumer_password',
config_path="path/to/your/config.yaml",
enable_ssl=False, # disable SSL
)
amos.create_channel()
amos.create_queue()
amos.connect_exchange()
amos.run_consumer(call_back)
config.yaml
host: "your.rabbitmq.host"
port: 5672 # Non-SSL default port is 5672
virtual_host: "your_virtual_host"
exchange: "your_exchange"
queue: "your_queue"
4. Use config file with SSL
your code
import json
from AmosMsg.AmosMsg import AmosMsg
def call_back(ch, method, properties, body):
message = json.loads(body.decode())
print(message)
ch.basic_ack(delivery_tag=method.delivery_tag)
print("%r" % body)
if __name__ == '__main__':
amos = AmosMsg(
msg_user='consumer_user',
msg_pass='consumer_password',
config_path="path/to/your/config.yaml",
enable_ssl=True, # enable SSL
)
amos.create_channel()
amos.create_queue()
amos.connect_exchange()
amos.run_consumer(call_back)
config.yaml
host: "your.rabbitmq.host"
port: 5671 # SSL default port is 5672
virtual_host: "your_virtual_host"
exchange: "your_exchange"
queue: "your_queue"
ca: "your/path/to/ca"
crt: "your/path/to/crt"
key: "your/path/to/key"
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
AmosMsg-0.0.1.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file AmosMsg-0.0.1.tar.gz
.
File metadata
- Download URL: AmosMsg-0.0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b22766be35c3ea2fd0856ef24d4a7671cacac980d4a4d896c06e665807ded6fb |
|
MD5 | 726a8c438082ecc0efe92a4f26e09cd8 |
|
BLAKE2b-256 | a4d4e1a0b1fc40cd45408ea51f85540bafa6b38e21d4aeb4965976d65dd0374e |
File details
Details for the file AmosMsg-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: AmosMsg-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5052b5ce45ef3ca0b2660b70627872865d9efead4291b12129346f24d9602854 |
|
MD5 | cc00f5906b7b6cfbc0e443380a599c03 |
|
BLAKE2b-256 | 52e1ec71630b58f9b945f6cc6d3e275737f0ee137bc3f5a628455c68a5ba4a9f |