1

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 => {
    });
});
DaiKeung
  • 1,077
  • 1
  • 19
  • 38

2 Answers2

1

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

Mike Urnun MSFT
  • 463
  • 3
  • 4
1

Looks like you are using the older azure-sb package that relies on the HTTP REST apis. If you instead use the newer @azure/service-bus package which uses the faster AMQP implementation, there is a deadletter() method on the message you receive that you can use to send the message to the dead letter queue.

Ramya Rao
  • 111
  • 5