

# Moving a job to a different queue
<a name="setting-up-queue-hopping-to-avoid-long-waits"></a>

A job stays in a `SUBMITTED` state, waiting to be processed, until the queue that you submit it to has available resources. To prevent long wait times, you can configure your job to automatically move to another queue after a set amount of time. This is called *queue hopping*. 

The most common use case for queue hopping is to move jobs from a reserved queue to an on-demand queue during a spike in usage. For example, you might automatically move jobs that sit in a `SUBMITTED` state for longer than 10 minutes.

Keep the following definitions in mind with queue hopping.

**Submission queue**  
The queue that you originally submit a job to is its *submission* queue.

**Destination queue**  
The queue that your job moves to when it hops queues is its *destination* queue.

**Wait time**  
The amount of time your job waits in its submission queue until it can hop to its destination queue.

**Hop**  
A job *hops* when it moves from its submission queue to its destination queue after its wait time elapses. A job that moves queues is also referred to as a *hopped job*.

**Note**  
When you set up queue hopping from a reserved queue to an on-demand queue, MediaConvert bills you according to the queue type that your job ultimately runs in. If your job runs in a reserved queue, MediaConvert doesn't bill you separately for the job because the cost is already covered by what you pay for your reserved queue. If your job runs in an on-demand queue, MediaConvert bills you for the job at the on-demand rate. 

**Topics**
+ [Setting up queue hopping](setting-up-queue-hopping.md)
+ [Setting priority for hopped jobs](job-priority-and-queue-hopping.md)
+ [Using accelerated transcoding with hopped jobs](accelerated-transcoding-queue-hopping.md)
+ [Viewing hopped job history](job-queue-hopping-history.md)
+ [Understanding queue hopping with paused queues](queue-hopping-with-paused-queues.md)

# Setting up queue hopping
<a name="setting-up-queue-hopping"></a>

When you set up queue hopping, you specify the *submission queue*, the *wait time*, and the *destination queue*. Typically, the submission queue is a reserved queue and the destination queue is an on-demand queue. The following tabs show different options for setting up queue hopping. 

------
#### [ Console ]

To set up queue hopping in the MediaConvert console:

1. On the **Create job** page, choose **Job management**.

1. Enable **Queue hopping**.

1. Enter the amount of time until your job can hop with **Wait minutes**.

1. For **Destination queue**, choose the queue that you want your job to hop to if it stays in the submission queue beyond its wait time.

1. Optionally, specify a new **Job priority** if your job hops to its destination queue. For more information, see [Setting priority for hopped jobs](job-priority-and-queue-hopping.md).

------
#### [ API, SDK, or the AWS CLI ]

To set up queue hopping in the API, SDK, or the AWS CLI, configure the settings for queue hopping under `HopDestinations`. This property is a direct child of `Jobs`, which is in the top level of the JSON job specification.

The following is an excerpt of a job settings JSON that hops to an on-demand queue after 10 minutes.

```
{
    "Settings": {
        "OutputGroups": [...],
        "Inputs": [...]
    },
    "HopDestinations": [
        {
        "WaitMinutes": 10,
        "Queue": "arn:aws:mediaconvert:us-west-2:111122223333:queues/ondemandqueue",
        "Priority": 0
        }
    ]
}
```

For more information, see the MediaConvert [API Reference](https://docs.aws.amazon.com/mediaconvert/latest/apireference/jobs.html#jobs-model-hopdestination).

------

# Setting priority for hopped jobs
<a name="job-priority-and-queue-hopping"></a>

When you set up a job for queue hopping, you can specify the priority for the job in the new queue. If you don't specify a new priority, the job keeps the priority number from its submission queue. 

If you use different guidelines for choosing the values for `priority` between the two queues, make sure to specify a new priority value for the job in the destination queue.

For information about setting the job's priority within the submission queue, see [Setting job priority](setting-the-priority-of-a-job.md).

The following tabs provide different options for setting the priority of a hopped job. 

------
#### [ Console  ]

To set the priority of a hopped job in the MediaConvert console:

1. Open the [Create job](https://console.aws.amazon.com/mediaconvert/home#/jobs/create) page in the MediaConvert console.

1. Choose **Job management** from the **Job settings** menu.

1. Enable **Queue hopping**.

1. Enter the **Job priority** for when your job hops to its destination queue.

1. Enter both **Wait minutes** and **Destination queue**. For more information, see [Moving a job to a different queue](setting-up-queue-hopping-to-avoid-long-waits.md).

------
#### [ API, SDK, or the AWS CLI  ]

You can set up a hopped jobs new priority by using the API, SDK, or the AWS CLI. To set it up, configure `Priority` under `HopDestinations`. This property is a direct child of `Jobs`, which is in the top level of the JSON job specification.

The following is an excerpt of a job settings JSON that sets a hopped job's priority to 25.

```
{
	"Settings": {
		"OutputGroups": [...],
		"Inputs": [...]
	},
	"HopDestinations": [
		{
			"WaitMinutes": 10,
			"Queue": "arn:aws:mediaconvert:us-west-2:111122223333:queues/ondemandqueue",
			"Priority": 25
		}
	]
}
```

For more information, see the MediaConvert [API Reference](https://docs.aws.amazon.com/mediaconvert/latest/apireference/jobs.html#jobs-model-hopdestination).

------

# Using accelerated transcoding with hopped jobs
<a name="accelerated-transcoding-queue-hopping"></a>

To reduce the transcoding time for certain jobs, use accelerated transcoding. In most cases, you submit accelerated jobs to on-demand queues, because reserved queues cannot run accelerated jobs. However, you can submit a job with **Accelerated transcoding** set **Preferred** to a reserved queue. When you do, if the job hops to an on-demand queue, it will run with acceleration enabled. For more information about accelerated transcoding, see [Accelerated transcoding](accelerated-transcoding.md) in the MediaConvert User Guide.

The following tabs provide different options for setting accelerated transcoding.

------
#### [ Console  ]

To set **Acceleration** to **Preferred** in MediaConvert console:

1. Open the [Create job](https://console.aws.amazon.com/mediaconvert/home#/jobs/create) page in the MediaConvert console.

1. Choose **Job management** from the **Job settings** menu.

1. Under **Acceleration**, choose **Preferred** by using the dropdown list.

------
#### [ API, SDK, or the AWS CLI  ]

To specify preferred acceleration by using the API, SDK, or the AWS CLI, configure `Mode` under `AccelerationSettings`. This property is a direct child of `Jobs`, which is in the top level of the JSON job specification.

The following is an excerpt of a job settings JSON that specifies queue hopping to an on-demand queue with accelerated transcoding.

```
{
	"Settings": {
		"OutputGroups": [...],
		"Inputs": [...]
	},
	"AccelerationSettings": {
		"Mode": "PREFERRED"
	},
	"HopDestinations": [
		{
			"WaitMinutes": 10,
			"Queue": "arn:aws:mediaconvert:us-west-2:111122223333:queues/ondemandqueue",
			"Priority": 25
		}
	]
}
```

For more information, see the MediaConvert [API Reference](https://docs.aws.amazon.com/mediaconvert/latest/apireference/jobs.html#jobs-model-accelerationsettings).

------

# Viewing hopped job history
<a name="job-queue-hopping-history"></a>

When a job hops queues, the values for the settings `queue` and `priority` remain how you set them when you created the job. You can see the values for the job's post-hop destination and queue priority. The following tabs provide two options for viewing a job's history and queue priority.

------
#### [ Console  ]

To see if your job hopped queues by using the MediaConvert console:

1. Open the [Jobs](https://console.aws.amazon.com/mediaconvert/home#/jobs/list) page in the MediaConvert console.

1. Select a **Job ID**.

1. Find the **Queue transition** section that shows the job priority before and after hopping. That section also shows the epoch **Timestamp** for when the job hopped, the **Source queue**, and the **Destination queue**.

------
#### [ AWS CLI  ]

The following `get-job` example returns a JSON response with information about your job.

```
aws mediaconvert get-job \
	--id 1234567890123-efg456
```

The following is an excerpt showing `QueueTransitions` in the JSON response when you run this command. The response shows your job's submission queue and destination queue.

```
"QueueTransitions": [
	{
		"Timestamp": 1672662636, 
		"SourceQueue": arn:aws:mediaconvert:us-west-2:111122223333:queues/submissionqueue,
		"DestinationQueue": arn:aws:mediaconvert:us-west-2:111122223333:queues/destinationqueue
	}
]
```

For more information about how to use the `get-job` command, see the [AWS CLI Command Reference](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/mediaconvert/get-job.html).

------

**Billing tags for hopped jobs**  
If you use billing tags on your jobs and set your billing tags source to **Queue**, the charges for your jobs are always listed under the tags for the submission queue. To track how much you were billed for a job that hops queues, you can set the billing tags source to **Job**. For more information about using tags to sort your AWS bill, see [Setting up AWS Elemental MediaConvert resources for cost allocation through tagging](setting-up-resources-for-catt.md).

**Note**  
Cost allocation based on queue only applies to jobs that run in on-demand queues. When your submission queue is a reserved queue and your job hops to an on-demand queue, the charges for that on-demand job appear in your cost allocation report. If you don't put tags on your reserved queue, those charges appear in the report unsorted.

**Listing hopped jobs**  
When you view your job, MediaConvert displays the queue that you submitted your job. For example, if you submit a job to `Queue1`, and it hops to `Queue2`, that job appears in lists that are filtered for `Queue1`. It doesn't appear in lists filtered for `Queue2`.

# Understanding queue hopping with paused queues
<a name="queue-hopping-with-paused-queues"></a>

Pausing a queue affects a job's queue hopping behavior. Jobs don't hop from a queue while it's paused, but they do hop freely to paused queues. This section describes what happens when you configure queue hopping *from* a paused queue or *to* a paused queue.

## Hopping from a paused queue
<a name="hopping-from-a-paused-queue"></a>

Jobs don't hop from a queue while it's paused. Queue hopping behavior depends on how long the queue is paused. Consider these two situations: 

**You submit a job to a queue, pause the queue for longer than the queue hopping wait time, then reactivate it.**  
In this situation, whether the job hops depends on where the job is in the queue. If there are any jobs ahead of it in the queue, the job hops to the destination queue. If there are no jobs ahead of it in the queue, MediaConvert processes it without hopping.

For example, imagine that you submit a job to `Queue1` with a wait time of 15 minutes and a destination of `Queue2`. Five minutes after you submit the job, you pause `Queue1`. Ten minutes later, the job remains in `Queue1`. Half an hour after that, you activate `Queue1`. At that time, there are no jobs ahead of it in `Queue1`, so the job runs from `Queue1`.

**You submit a job to a queue. You pause the queue and then reactivate it before the wait time passes.**  
In this situation, the time that the queue is paused doesn't affect queue hopping at all.

For example, imagine that you submit a job to `Queue1` with a wait time of 15 minutes and a destination of `Queue2`. Five minutes after you submit the job, you pause `Queue1`. One minute later, you reactivate `Queue1`. Nine minutes later (15 minutes after you submitted the job), there are still jobs ahead of it in the queue. Therefore, the job hops to `Queue2`, as though you hadn't paused the queue.

## Hopping to a paused queue
<a name="hopping-to-a-paused-queue"></a>

Jobs hop freely from active queues to paused queues. For example, imagine that you submit a job to `Queue1` with a wait time of 15 minutes and a destination of `Queue2`. Then, five minutes after you submit the job, you pause `Queue2`. Ten minutes later (15 minutes after you submit the job), the job hops to `Queue2` and remains there, waiting until you activate the queue.