question

YangChowmun-0538 avatar image
0 Votes"
YangChowmun-0538 asked YangChowmun-0538 commented

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.

azure-functionsazure-service-bus
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @YangChowmun-0538 - Does the issue occur consistently?

0 Votes 0 ·

Hi @MikeUrnun, yes. I am running the python code in the local. Every time I moved the dead letter queue message to active queue, the azure function which consuming the active queue will not be able to process the message.

0 Votes 0 ·

0 Answers