# Task Queues and naming best practices

> For the complete documentation index, see [llms.txt](https://docs.temporal.io/llms.txt).
> Any documentation page is available as raw Markdown by appending `.md` to its URL.
> For related questions, query https://docs.temporal.io/api/retrieve?q=<question>&jtb=<job-to-be-done>&src=md-page&agent=<your-name> (no auth; returns JSON `{content, source_url, page_url}`, with `source_url` pointing to Markdown for docs pages). Don't include personal data or credentials.

> A mismatch in Task Queue names creates separate queues, preventing the Worker from receiving tasks and stalling Workflow Execution.

The Temporal Service maintains a set of Task Queues, which Workers poll to see
what work needs to be done. Each Task Queue is identified by a name, which is
provided to the Temporal Service when launching a Workflow Execution.

## Set the same name on the Client and the Worker

**Python**

**Excerpt of code used to start the Workflow in Python**

```python
client = await Client.connect("localhost:7233", namespace="default")

# Execute a workflow
result = await client.execute_workflow(
    GreetingWorkflow.run,
    name,
    id="my-workflow",
    task_queue="my-task-queue-name",
)
```

**Excerpt of code used to configure the Worker in Python**

```python
worker = Worker(
    client,
    task_queue="my-task-queue-name",
    workflows=[GreetingWorkflow],
    activities=[activities.say_hello],
)
```

**Go**

**Excerpt of code used to start the Workflow in Go**

```go
options := client.StartWorkflowOptions{
    ID:        "my-workflow",
    TaskQueue: "my-task-queue-name",
}

run, err := c.ExecuteWorkflow(ctx, options, ProcessOrderWorkflow, input)
```

**Excerpt of code used to configure the Worker in Go**

```go
w := worker.New(c, "my-task-queue-name", worker.Options{})
```

**Java**

**Excerpt of code used to start the Workflow in Java**

```java
WorkflowOptions options = WorkflowOptions.newBuilder()
        .setWorkflowId("my-workflow")
        .setTaskQueue("my-task-queue-name")
        .build();

MyWorkflow workflow = client.newWorkflowStub(MyWorkflow.class, options);
```

**Excerpt of code used to configure the Worker in Java**

```java
Worker worker = factory.newWorker("my-task-queue-name");
```

**TypeScript**

**Excerpt of code used to start the Workflow in TypeScript**

```typescript
await client.workflow.start(OrderProcessingWorkflow, {
  args: [order],
  taskQueue: 'my-task-queue',
  workflowId: `workflow-order-${order.id},`,
});
```

**Excerpt of code used to configure the Worker in TypeScript**

```typescript
const worker = await Worker.create({
  taskQueue: 'my-task-queue',
  connection,
  workflowsPath: require.resolve('./workflows'),
  activities,
});
```

**.NET**

**Excerpt of code used to start the Workflow in C# and .NET**

```csharp
var options = new WorkflowOptions(
            id: "translation-workflow",
            taskQueue: "my-task-queue");

// Run workflow
var result = await client.ExecuteWorkflowAsync(
    (TranslationWorkflow wf) => wf.RunAsync(input),
    options);
```

**Excerpt of code used to configure the Worker in C# and .NET**

```csharp
using var worker = new TemporalWorker(
    client,
    new TemporalWorkerOptions("my-task-queue")
    .AddAllActivities(activities)
    .AddWorkflow<TestWorkflow>());
```

## Define the name as a shared constant

Since Task Queues are created dynamically when they are first used, a mismatch
between these two values does not result in an error. Instead, it will result
in the creation of two different Task Queues. Consequently, the Worker will
not receive any tasks from the Temporal Service and the Workflow Execution
will not progress. Therefore, we recommend that you define the Task Queue name
in a constant that is referenced by the Client and Worker if possible, as this
will ensure that they always use the same value.

**Python**

**Excerpt of code used to define a constant with the Task Queue name in Python (in a shared.py file)**

```python
TASK_QUEUE_NAME = "my-task-queue-name"
```

**Excerpt of code used to start the Workflow, referencing the constant
defined with the Task Queue name in Python**

```python
from shared import TASK_QUEUE_NAME

...

client = await Client.connect("localhost:7233", namespace="default")

# Execute a workflow
result = await client.execute_workflow(
    GreetingWorkflow.run,
    name,
    id="my-workflow",
    task_queue=TASK_QUEUE_NAME,
)
```

**Excerpt of code used to configure the Worker, referencing the constant
defined with the Task Queue name in Python**

```python
worker = Worker(
    client,
    task_queue=TASK_QUEUE_NAME,
    workflows=[GreetingWorkflow],
    activities=[activities.say_hello],
)
```

**Go**

**Excerpt of code used to define a constant with the Task Queue name in Go**

```go
package app 

const TaskQueueName = "my-taskqueue-name"
```

**Excerpt of code used to start the Workflow, referencing the constant defined with the Task Queue name in Go**

```go
options := client.StartWorkflowOptions{
    ID:        "my-workflow",
    TaskQueue: app.TaskQueueName,
}

run, err := c.ExecuteWorkflow(ctx, options, ProcessOrderWorkflow, input)
```

**Excerpt of code used to configure the Worker, referencing the constant defined with the Task Queue name in Go**

```go
w := worker.New(c, app.TaskQueueName, worker.Options{})
```

**Java**

**Excerpt of code used to define a constant with the Task Queue name in Java**

```java
package app;

public class Constants {

  public static final String taskQueueName = "my-task-queue-name";

}
```

**Excerpt of code used to start the Workflow, referencing the constant defined with the Task Queue name in Java**

```java
WorkflowOptions options = WorkflowOptions.newBuilder()
        .setWorkflowId("my-workflow")
        .setTaskQueue(Constants.taskQueueName)
        .build();

MyWorkflow workflow = client.newWorkflowStub(MyWorkflow.class, options);
```

**Excerpt of code used to configure the Worker, referencing the constant defined with the Task Queue name in Java**

```java
Worker worker = factory.newWorker(Constants.taskQueueName);
```

**TypeScript**

**Excerpt of code used to define a constant with the Task Queue name in TypeScript**

```typescript
const TASK_QUEUE_NAME = 'my-taskqueue-name';
```

**Excerpt of code used to start the Workflow, referencing the constant defined with the Task Queue name in TypeScript**

```typescript
import { TASK_QUEUE_NAME } from './shared';

// additional code would follow

await client.workflow.start(OrderProcessingWorkflow, {
  args: [order],
  taskQueue: TASK_QUEUE_NAME,
  workflowId: `workflow-order-${order.id},`,
});
```

**Excerpt of code used to configure the Worker, referencing the constant defined with the Task Queue name in TypeScript**

```typescript
import { TASK_QUEUE_NAME } from './shared';

// additional code would follow

const worker = await Worker.create({
  taskQueue: TASK_QUEUE_NAME,
  connection,
  workflowsPath: require.resolve('./workflows'),
  activities,
});
```

**.NET**

**Excerpt of code used to define a constant with the Task Queue name in C# and .NET**

```csharp
public static class WorkflowConstants
{
    public const string TaskQueueName = "translation-tasks";
}
```

**Excerpt of code used to start the Workflow, referencing the constant defined with the Task Queue name in C# and .NET**

```csharp
var options = new WorkflowOptions(
            id: "translation-workflow",
            taskQueue: WorkflowConstants.TaskQueueName);

// Run workflow
var result = await client.ExecuteWorkflowAsync(
    (TranslationWorkflow wf) => wf.RunAsync(input),
    options);
```

**Excerpt of code used to configure the Worker, referencing the constant defined with the Task Queue name in C# and .NET**

```csharp
using var worker = new TemporalWorker(
    client,
    new TemporalWorkerOptions(WorkflowConstants.TaskQueueName)
    .AddAllActivities(activities)
    .AddWorkflow<TranslationWorkflow>());
```

## When a shared constant is not available

A shared constant is not always possible, such as when the Client that starts the Workflow runs on another system or
is written in a different programming language.
