Using Pika with Django (Event-based microservice using django rest framework)

1.3k Views Asked by At

anyone here has experience implementing pika with Django? I am basically running an event-based microservice using django rest framework. And using RabbitMQ as the message bus. I know the default library to use in this case would be Celery, but I am looking for a lighter version where I can just implement a simple pub / sub on the messages.

Has anyone implemented such a service using pika before? My question is more how do you spawn pika as a separate process together with Django? Or is there a more elegant solution out there?

Thanks in advance.

--- UPDATE ---

What we ended up doing was:

For the publisher:

  • We spawn a separate thread (or many if you need to publish a high volume/ sec) that keeps a pika connection alive.

For the subscriber:

  • We spawn a separate worker process (in a separate container) that has the django context (using django.setup()) which consumes the messages from RabbitMQ
0

There are 0 best solutions below