I need to deadletter a message when the API respose is not 200. The message is not initially send to the main queue , I need to directly send the message to the deadletter.
Came accross deadLetter() method , but the argument should be of type 'ServiceBusReceiverClient' and manually converting to ServiceBusReceiverClient type is not possible since the constructors are private. Is there any efficient way to directly deadletter a message through a Java application? The queue is used to send other valid messages as well so making some configuration changes that applies to all messages cannot be implemented .
As you mentioned, we can send the messages to the queue first and those messages will sent to the deadLetter queue.
Code :
Output :
It ran successfully as below,
The message is sent to the main queue first as below,
And, quickly sent that message to the deadletter queue as below.