You can run the async code by importing Client from upstash_qstash.asyncio and awaiting the methods.

Get all messages with pagination using cursor

Since the DLQ can have a large number of messages, they are paginated. You can go through the results using the cursor.

from upstash_qstash import Client

dlq = client.dlq()
all_messages = []
cursor = None
while True:
  res = dlq.list_messages({"cursor": cursor})
  all_messages.extend(res["messages"])
  cursor = res.get("cursor")
  if cursor is None:
    break

Get a message from the DLQ

from upstash_qstash import Client

dlq = client.dlq()
msg = dlq.get("dlqId")

Delete a message from the DLQ

from upstash_qstash import Client

dlq = client.dlq()
dlq.delete("dlqId")