Handling service bus deadletter queue

Yang Chowmun 411 Reputation points
2021-09-07T16:52:20.037+00:00

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.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
544 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,263 questions
{count} votes