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.3

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.3.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.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: my_rabbitmq_package-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 c41b45796049708e33c7f01bc4ddf33f029ed2760b876b36a9d3bbf8a26d6441
MD5 895f46b95acf558afd5fe975511bfe9c
BLAKE2b-256 171bc4992c9df9cd52c0c1cdf0da1e42601790b2ab4a2c4989e0fa0412292310

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for my_rabbitmq_package-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c12176ccfc4d9b1690ae6e677dbfabf4d0f59f59eae65f289e0e1d41944a12a
MD5 2bc45225ec778476d7f4bb6da785a86a
BLAKE2b-256 7f23665721a495a65fcc07706399a1a1f959cc638f4f09e1438d68dcb79f3d66

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