Handling service bus deadletter queue
I am trying to read from dead letter queue and pass the msg back into original queue.
I am using the code in this link to do it except that I did not include the 'subject'
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py
I have also tried to use the codes below to do the same.
dlq_receiver = servicebus_client.get_queue_receiver(queue_name=Queue_name, sub_queue=ServiceBusSubQueue.DEAD_LETTER)
msgs_to_send = []
with dlq_receiver:
received_dlq_msgs = dlq_receiver.receive_messages(max_message_count=1, max_wait_time=1)
for msg in received_dlq_msgs:
msgs_to_send.append(msg)
dlq_receiver.complete_message(msg)
print(msg)
with ServiceBusClient.from_connection_string(connectionString) as client:
with client.get_queue_sender(Queue_name) as sender:
sender.send_messages(msgs_to_send)
Both of the codes can read and send dead letter message back to the original queue but the sent message was not able to be consumed by trigger function. After restarting the function, the problem is solved.
Is there any steps missing which lead to this error?
Thanks.