Search code examples
node.jsservicebusdead-letter

How to send service bus message to deadletter queue in NodeJS?


How can I send message to deadletter queue?

serviceBusService.receiveQueueMessage(MESSAGE_QUEUE, {isPeekLock: true}, (error, message) => {
    ...... // want to put message to deadletter queue if there is exception
    serviceBusService.deleteMessage(message, error => {
    });
});

Solution

  • Mostly, you'd want to rely on the system to decide when to move a message to DLQ and make it the messaging engine's responsibility as much as possible (and not explicitly put a message on DLQ.) It also appears that the guidance in this scenario was provided via documentation here: How to handle application crashes and unreadable messages