Skip to main content

A Python package for RabbitMQ interactions

Project description

# my_rabbitmq_package

A Python package for RabbitMQ interactions.

## Installation

You can install the package using pip:

```bash
pip install my-rabbitmq-package==0.1.4

Publisher Usage

from my_rabbitmq_package.publisher import RabbitMQPublisher

# Initialize the publisher
rabbitmq_publisher = RabbitMQPublisher(host='localhost', port=5672, username='guest', password='guest')

# Declare the queue
rabbitmq_publisher.declare_queue('hello')

# Publish a message
message = "Hello, RabbitMQ!"
rabbitmq_publisher.publish_message(message, 'hello')

# Close the connection
rabbitmq_publisher.close_connection()

Consumer Usage

from my_rabbitmq_package.consumer import RabbitMQConsumer
import threading

# Initialize the consumer
rabbitmq_consumer = RabbitMQConsumer(host='localhost', port=5672, username='guest', password='guest')

# Declare the queue
rabbitmq_consumer.declare_queue('hello')

# Define event handler functions
@rabbitmq_consumer.event_manager.on(event="message_received")
def handle_message_received(data: bytes):
    print(" [*] Event handler 'handle_message_received' triggered")
    print(f"Processing message: {data.decode()}")

@rabbitmq_consumer.event_manager.on(event="stop_consumer")
def handle_stop_consumer():
    print(" [*] Event handler 'handle_stop_consumer' triggered")
    rabbitmq_consumer.stop()

# Start consuming messages in a separate thread
consume_thread = threading.Thread(target=rabbitmq_consumer.consume_messages, args=('hello',))
consume_thread.start()
consume_thread.join()

# Close the connection
rabbitmq_consumer.close_connection()

Running Tests

You can run the tests using pytest. First, make sure you have pytest installed:

pip install pytest

Then, run the tests:

pytest tests/

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

my_rabbitmq_package-0.1.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

my_rabbitmq_package-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file my_rabbitmq_package-0.1.4.tar.gz.

File metadata

  • Download URL: my_rabbitmq_package-0.1.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for my_rabbitmq_package-0.1.4.tar.gz
Algorithm Hash digest
SHA256 bc2544f55a10153a3b6671caaa436b9ceeefb88047e3427e7bdb733898625c3c
MD5 5585d180c8d5332c75709bac63832e46
BLAKE2b-256 74fd2ca9d061064a57e509a97d556bd861312f797f379e507233113c7f056ca8

See more details on using hashes here.

File details

Details for the file my_rabbitmq_package-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for my_rabbitmq_package-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 50bb620c87cb709e338f84debf1558eac6abc9e2afda3a1e9738fb0e0a273f1e
MD5 16f3c648d5feaf764d16d791ce52178d
BLAKE2b-256 fe3628be41d35b6b7fbaa572012573b4aa7e1821ec2e9280df9faf20d5c64546

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