@Anonymous Thanks for reaching out.
Message will be moved to dead letter queue only due to the reasons that are mentioned here. There is no way/method to move the message to the dead letter queue.
HeaderSizeExceeded | The size quota for this stream has been exceeded. |
TTLExpiredException | The message expired and was dead lettered. See the Time to live section for details. |
Session ID is null. | Session enabled entity doesn't allow a message whose session identifier is null. |
MaxTransferHopCountExceeded | The maximum number of allowed hops when forwarding between queues has been exceeded. This value is set to 4. |
MaxDeliveryCountExceeded | Message couldn't be consumed after maximum delivery attempts. See the Maximum delivery count section for details. |
In case if you found that you don't want to consume a particular message then you need to keep on calling the abandoned method on that particular message so the max delivery count is reach and then message will be moved to the dead letter queue.
we are getting no messages in the receiver . but if we have 2 messages in the queue, we will get messages under receiver.
If there are no message in the queue, then you will receive the empty response by receiver.receiveMessages and as I see you are trying to receive one message. Can you please confirm if you have validate that the message was send form your client? Can you use service bus explorer/or azure portal to validate the message count or peek the message to confirm. As this need to further troubleshoot as per the code receiver.receiveMessages(1) it should receive one message. There could be scenario where you running your application and there was no message received then it may wait for 30 seconds to again verify if there are any new messages received.