2

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
fahyik yong
  • 141
  • 6
  • 1
    My 2 cents - disregard if you want - all of this depends on the deployment. If you know you are doing AWS then probably easier to use SQS and leverage their stack. Otherwise I'd set up the rabbitmq/ redis/ pika in containers that then just get called from the modelview in DRF. But then the big question is handling crontab or recurring polling, but a lot of options exist there. – sahutchi Dec 27 '17 at 17:55

0 Answers0