Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This sample demonstrates retrieving a message from a dead letter queue, editing it and
sending it back to the main queue.
Prior to running this sample, run the sample in movingMessagesToDLQ.js file to move a message
to the Dead Letter Queue
*/
const { ServiceBusClient, ReceiveMode, QueueClient } = require("@azure/service-bus");
// Define connection string and related Service Bus entity names here
const connectionString = "";
const queueName = "";
// If deadlettered messages are from Subscription, use `TopicClient.getDeadLetterTopicPath` instead
const deadLetterQueueName = QueueClient.getDeadLetterQueuePath(queueName);
const sbClient = ServiceBusClient.createFromConnectionString(connectionString);
async function main() {
try {
await processDeadletterMessageQueue();
} finally {
await sbClient.close();
}
}
async function processDeadletterMessageQueue() {
const queueClient = sbClient.createQueueClient(deadLetterQueueName);
const receiver = queueClient.createReceiver(ReceiveMode.peekLock);
const messages = await receiver.receiveMessages(1);
This sample demonstrates retrieving a message from a dead letter queue, editing it and
sending it back to the main queue.
Prior to running this sample, run the sample in movingMessagesToDLQ.ts file to move a message
to the Dead Letter Queue
*/
import { ServiceBusMessage, ServiceBusClient, ReceiveMode, QueueClient } from "@azure/service-bus";
// Define connection string and related Service Bus entity names here
const connectionString = "";
const queueName = "";
// If deadlettered messages are from Subscription, use `TopicClient.getDeadLetterTopicPath` instead
const deadLetterQueueName = QueueClient.getDeadLetterQueuePath(queueName);
const sbClient: ServiceBusClient = ServiceBusClient.createFromConnectionString(connectionString);
async function main(): Promise {
try {
await processDeadletterMessageQueue();
} finally {
await sbClient.close();
}
}
async function processDeadletterMessageQueue(): Promise {
const queueClient = sbClient.createQueueClient(deadLetterQueueName);
const receiver = queueClient.createReceiver(ReceiveMode.peekLock);
const messages = await receiver.receiveMessages(1);