Reputation: 5472
In my Django project I implemented Celery, which is running using RabbitMQ backend.
Celery
puts my tasks into queue, and then under certain conditions runs them. That being said, I basically interact with RabbitMQ
message queue exclusively using Celery
python interface.
I want just to push simple string message into RabbitMQ
queue, which should be consumed by 3rd party application.
There is a way how to directly connect to RabbitMQ
using Pika library. However I would find it a little clunky - If I have already Celery
connected to RabbitMQ
, why not use it (if possible) to send simple messages to a specific queue, instead opening another connection using mentioned Pika
library.
Any insights appreciated.
Upvotes: 2
Views: 1265
Reputation: 19822
You cannot use Celery to send arbitrary messages to your RabbitMQ server.
However, considering that you already use RabbitMQ as a broker, which means you already have all the necesary RabbitMQ support (py-amqp supports it either directly, or via librabbitmq), you can easily send messages to the MQ server from your Celery tasks. If you for whatever reason do not like py-amqp, you may use Pika as you mentioned already.
Upvotes: 2