Skip to main content

pika-based RabbitMQ connector with built in JSON serialization/deserialization

Project description

rabbitqm-alphamoon

[image [image

pika-based RabbitMQ connector with built in JSON serialization/deserialization


Features

  • publishing: publish(message)
  • getting number of messages in the queue: message_count
  • consuming (forever, i.e. with a callback function): consume_forever(callback_fun)

See code examples in the "Examples" section.

Requirements

pika==1.2.0

Installation

You can install "rabbitmq-alphamoon" via pip from PyPI:

$ pip install rabbitmq-alphamoon

Examples

Initialization

import pika
from rabbitmq_alphamoon import RabbitMQConnector

parameters = pika.ConnectionParameters(
    host=rabbitmq_host,
    port=rabbitmq_port,
    credentials=pika.PlainCredentials(
        username=rabbitmq_username,
        password=rabbitmq_password,
    ),
)

queue = RabbitMQConnector(
    connection_parameters=parameters,
    queue=queue_name,
)

Publishing

message = {'foo': 'bar'}

with queue.open_connection():
    queue.publish(message)

Getting a number of the messages in the queue

message_count = queue.message_count

Consuming

def process_message(message):
    print(message)

with queue.open_connection():
    queue.consume_forever(process_message_callback=process_message)

Short form for one-time usage of connector

If you do not need to reuse the connector, you can initialize and open connection without assignment of connector to a variable before calling open_connection context manager. This may come in handy especially in case of consuming, where connector is usually used only to call consume_forever function.

with RabbitMQConnector(
    connection_parameters=parameters,
    queue=queue_name,
).open_connection() as queue:
   queue.consume_forever(process_message_callback=process_message)

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "rabbitmq-alphamoon" is free and open source software

Issues

If you encounter any problems, please email us at dev@alphamoon.ai, along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbitmq-alphamoon-0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rabbitmq_alphamoon-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file rabbitmq-alphamoon-0.1.1.tar.gz.

File metadata

  • Download URL: rabbitmq-alphamoon-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for rabbitmq-alphamoon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6371efb783df23959605b1585c62b219d2432dcc2b5aa40e70822996aa61d2ec
MD5 f437fddd00cbc472be82acc49ef6142d
BLAKE2b-256 b382bc6c26c2ee8661b1e05f54fd8ca8bb1677dfd27c6539f763b97ca9d89f1c

See more details on using hashes here.

File details

Details for the file rabbitmq_alphamoon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rabbitmq_alphamoon-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for rabbitmq_alphamoon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3839310d97214047094c6cff50e3e2a227c2f2ac413c4f84580093b610d94020
MD5 2fa94ce69f85f67766654ff3b7272983
BLAKE2b-256 5be5b7981229cf2463475e703f52ee2d22406975d32a296f7d926322e8ea55ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page