I could not find any examples to send message to deadletter queue manually.
let { ServiceBusClient, ReceiveMode } = require('@azure/service-bus'),
serviceBusClient = ServiceBusClient.createFromConnectionString(SERVICE_BUS_SECRET),
queueClient = serviceBusClient.createQueueClient(QUEUE),
receiver = queueClient.createReceiver(ReceiveMode.peekLock);
const onMessageHandler = async (brokeredMessage) => {
await brokeredMessage.deadletter({
deadletterReason: 'testingReason',
deadLetterErrorDescription: 'testingDesc'
});
};
const onErrorHandler = (error) => {
console.log(error);
};
receiver.registerMessageHandler(onMessageHandler, onErrorHandler);
When I run above code, there is error like deadletter() is not defined.
Regarding the issue, please refer to the following code