# Requeue All (/sdks/csharp/how-to/queues/requeue-all)



## Overview [#overview]

**Requeue all** moves an entire batch of polled messages to a different channel in one server-side operation, without republishing them from the client. Reach for it when you need to make a routing decision after looking at a batch — shovel a stuck batch into a review queue, redirect it to a priority pipeline, or migrate messages off a channel that's being retired, all while the source queue is cleared atomically.

It works against the batch returned by a manual poll: after receiving messages with `AutoAck = false`, call `batch.ReQueueAllAsync(destinationChannel)` to move every message held in that batch to the destination channel, removing them from the source at the same instant. The messages keep their original body, tags, and policies — the broker relocates them, it doesn't recreate them.

**Gotchas:** requeuing is all-or-nothing for the batch — there's no per-message filter, so split the batch yourself first if only some messages should move. The destination channel is an ordinary queue with no special semantics; nothing consumes it automatically. And the operation only affects messages still locked in the batch — anything already acked or expired out of it is gone before `ReQueueAllAsync` runs.

## Prerequisites [#prerequisites]

* KubeMQ server running on `localhost:50000`
* C# SDK installed (`dotnet add package KubeMQ.SDK.CSharp`)

## Code [#code]

```csharp title="Program.cs"
// KubeMQ .NET SDK — QueuesStream: ReQueueAll via Batch
//
// This example demonstrates receiving messages via the downstream receiver API
// and re-routing all messages to a different channel using batch.ReQueueAllAsync().
// This is useful for dead-letter queue (DLQ) patterns.
//
// Prerequisites:
//   - KubeMQ server running on localhost:50000
//   - Send some messages to "csharp-queues.requeue-all" first
//   - dotnet run

using KubeMQ.Sdk.Client;
using KubeMQ.Sdk.Queues;

await using var client = new KubeMQClient(new KubeMQClientOptions
{
    ClientId = "csharp-queues-requeue-all-client",
});
await client.ConnectAsync();

Console.WriteLine("Connected to KubeMQ server");

await using var receiver = await client.CreateQueueDownstreamReceiverAsync();

var batch = await receiver.PollAsync(new QueuePollRequest
{
    Channel = "csharp-queues.requeue-all",
    MaxMessages = 10,
    WaitTimeoutSeconds = 5,
    AutoAck = false,
});

Console.WriteLine($"Received {batch.Messages.Count} messages");

if (batch.HasMessages)
{
    await batch.ReQueueAllAsync("csharp-queues.dlq");
    Console.WriteLine("All messages re-queued to 'csharp-queues.dlq'.");
}

Console.WriteLine("Done.");

```

## How It Works [#how-it-works]

* `batch.ReQueueAllAsync(destinationChannel)` atomically moves all messages in the locked batch to the specified destination channel in one server-side operation.
* Messages are not re-sent by the client — the broker moves them internally, preserving their original metadata, body, and policy fields.
* This is a key building block for DLQ shovelling: a background worker polls the dead-letter queue and re-routes fixable messages back to the source queue after an operator corrects the issue.
* The destination can be any channel name — including the original source channel for a simple retry, or a different queue for escalation routing.

## Related [#related]

* [Pattern overview](/learn/queues/getting-started)
* [C# SDK Reference](/sdks/csharp/reference)
* [Send & Receive](/sdks/csharp/tutorials/send-receive)
* [Ack All](/sdks/csharp/how-to/queues/ack-all)
