1

I am using the azure-sdk-for-js to subscribe a permanently-running Node process to a service bus subscription. For some reason, when using registerMessageHandler it will work for a week, before failing without ever calling the registered error handler.

I have not found any events that are called from either the ServiceBusClient, SubscriptionClient, or Receiver that are being sent when this connection fails. I can work around this by monitoring how many times processMessage is called and killing the process when it has not been called recently, but this feels like a bad hack. I could also kill the container every 6 days, but that feels like a poor solution as well. I also could poll the Receiver's isClosed property, but I don't understand what is causing the link to close.

I am seeing no errors logged of any type, registerMessageHandler just stops being called after a week. My expectation is that there would be some event handler I could register at the Receiver, SubscriptionClient, or ServiceBusClient level that would trigger when the link has closed.

this.azureServiceBusReceiver.registerMessageHandler(
  this.processMessage.bind(this),
  (err: any) => {
    // We should only retry retryable errors, otherwise exit the process as its not healthy
    if (!err.retryable) {
      logger.error({ err }, `Unretryable error, killing container.`);
      this.azureServiceBusReceiver.close().then(() => {
        process.exit(1);
      });
    }
    logger.error(
      { err },
      `Retryable error reading from Azure ServiceBus`
    );
  },
  { maxConcurrentCalls: MAXIMUM_CONCURRENCY }
);
Alex Petty
  • 28
  • 3

0 Answers0