coders51 / rabbitmq-stream-js-client

rabbitmq-stream-js-client
MIT License
34 stars 5 forks source link

[Question] Async ConsumerFunc #214

Open AmauryD opened 1 month ago

AmauryD commented 1 month ago

I noticed that the ConsumerFunc does not support async, so the client doesn't wait for the consumer function to finish before processing more messages. The problem is that my CPU becomes overwhelmed when receiving 1,000,000 messages in a short amount of time.

Is there a way to solve this problem ? The only temporary fix I have is to enqueue all the asynchronous calls in a queue, but that seems a bit overkill and not very efficient.

const consumer = await this.client.declareConsumer({
            ...
 },  (message) => {
        this.worker.enqueue(async () => {
           ...
        })
 })

Thank you,

icappello commented 1 month ago

Hello, sorry for the delay. We'll get back to you in the following days