Muhammad Omer
Muhammad Omer

Reputation: 21

Can we read queue data created by bullmq in nodejs with python

I am currently running application in node.js and need to write python code for OCR services but for communication i am using Bullmq right now. I need to Publish data from Bullmq into queue and consume that data using Python Is this possible ?. Or any workaround for it ? Really need help on this.

Currently I have tried this approach using Bullmq and celery but they don't work together. What my understanding is that they are both use different underlying packages to push and retrieve data from redis so if i start a worker in celery on same queue for it that queue would be different then bullmq. Please tell if my understanding is right ?

Upvotes: 2

Views: 1453

Answers (1)

Michiel
Michiel

Reputation: 1

BullMQ now (at the time of writing) has an experimental Python package that can be installed using pip.

pip install bullmq

You can then add jobs or consumers using the Queue and Worker classes from the package.

Example for adding a new job:

from bullmq import Queue

queue = Queue("myQueue")
await queue.add("myJob", { "foo": "bar" })
await queue.close()

Example for adding a consumer:

from bullmq import Worker

async def process(job):
    return doSomethingAsync(job)

worker = Worker("myQueue", process)
await worker.close()

This code can also be found in BullMQs docs: https://docs.bullmq.io/python/introduction

Unfortunately, it is still in development and not advised for production code, but it might do the job in your use case.

Upvotes: 0

Related Questions