Fusion
Fusion

Reputation: 5472

Celery + RabbitMQ - Use Celery for simple messaging

In my Django project I implemented Celery, which is running using RabbitMQ backend.

What celery does:

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.

Problem:

I want just to push simple string message into RabbitMQ queue, which should be consumed by 3rd party application.

What I tried:

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

Answers (1)

DejanLekic
DejanLekic

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

Related Questions