0

MS-(A) sends hundred of messages to a Azure service bus - topic, on the other side MS-(B) receives those messages by implementing AMQP subscribe

this.subscription = this.receiver.subscribe({
                        processMessage: this.onMessage,
                        processError: this.onError
                    });

async onMessage(message) {
        await this.eventHandler(message)
    }

public async eventHandler(message): Promise<void> {

      console.log('before')

      await Utilities.sleep(5000)

      console.log('after')
}

The result is that the messages received in a sync mode instead of parallel. Meaning that till the handler not sends response, the other messages won't be received. I'd expect to read more messages till go to await.

current result: before (waiting for 5 sec) after

expected result: before before before ... after (after 5 sec)

How to implement it so messages keep received while the other are sleeping or in other words as a parallel mode?

alonabr11
  • 1
  • 1
  • 4

1 Answers1

0

I found that subscribe function can have options as a parameter.

subscribe(handlers: MessageHandlers, options?: SubscribeOptions): { close: any }

The object options of type SubscribeOptions contains prop maxConcurrentCalls which is enable to control the number of request to pull from a subscription.

alonabr11
  • 1
  • 1
  • 4