# Queues

Doddle can process multiple queues and each one can have a different priority.

### Implementation details

The priority for a queue is a value between 0 and 1. The lower the number, the higher the priority.

Queue names **must** only consist of lowercase letters, digits, underscore, and dash (since 1.7.6) characters only.

A queue can also be locked and unlocked.  Workers will be not pick up jobs associated to a queue that has been locked.

### Defining queues

Queues can be defined by using the client:

```java
client.queues().create(options -> {
   return options.name("high")
                 .priority(0f);
});
```

### Operations

#### Fetch queues

```java
List<Queue> all = client.queues().all();
```

#### Fetch a queue by its identifier

```java
String id = "56c8576b-ca5d-49ec-b0d8-029074a0f18a";
Optional<Queue> queue = client.queues().id(id);
```

#### Fetch a queue by its name

```java
Optional<Queue> queue = client.queues().name("high");
```

#### Delete a queue

{% hint style="danger" %}
This will throw an error if there are jobs associated to the queue
{% endhint %}

```java
String id = "56c8576b-ca5d-49ec-b0d8-029074a0f18a";
client.queues().delete(id);
```

#### Delete all queues

{% hint style="danger" %}
If a queue has jobs associated to it then it will not be deleted
{% endhint %}

```java
client.queues().deleteAll();
```

#### Lock and unlock queues

```java
client.queues().lockAll();
client.queues().unlockAll();
client.queues().lock("56c8576b-ca5d-49ec-b0d8-029074a0f18a");
client.queues().unlock("56c8576b-ca5d-49ec-b0d8-029074a0f18a");
```
