<a id="queue-load"></a>

<a id="spool-startup"></a>

# Spool startup

Upon startup the spool directory ([`spool.path`](config_startup.html.md#confval-spool.path) directive) is scanned for queued messages (.hqf files). The queue files are check for read and write permission by the running process (so that they may be updated and unlinked).
The files are then opened and parsed by multiple concurrent threads ([`spool.loader.threads`](config_startup.html.md#confval-spool.loader.threads) directive) before either adding them to the defer queue, hold queue or active queue.

> * If there is an error during the load the file is skipped and an error is logged.
> * If the file is empty or contains no queue information (hence from an incomplete transaction), you may choose to unlink, rename, ignore the file (`spool.corrupt` directive)

<a id="queue-ondisk"></a>

<a id="on-disk-format"></a>

# On-disk format

Queued messages and their metadata is written to disk, so that they can be re-loaded into
the MTA in case the *smtpd* [program](install.html.md#comp-programs) is restarted. The on-disk metadata
can be inspected with the *hqfcat* Python script:

```console
$ hqfcat /var/spool/halon/queue/66/662ffb4a-02d1-11ea-bcf7-06f091ceb4dc.hqf
[
  {
    "status": "QUEUE",
    "retry": 23,
    "retryts": 1573508496,
    "transportid": "mx",
    "ts": 1573290908,
    ...
```

which produces an output similar to the regular [command line interface](cli.html.md):

```console
$ halonctl queue list --id b186d406-0c36-11ea-8dda-005056914940:1 --json
[
  {
    "localips": [],
    "tags": [],
    "metadata": {},
    "id": {
      "transaction": "b186d406-0c36-11ea-8dda-005056914940",
      "queue": 1
    },
    ...
```

You can view the message including modifications made by the end-of-DATA [script](https://docs.halon.io/hsl/) using the *hqfeml* script.
The `-R` flag is the recipient queue id. Without the `-R` flag the original message is displayed.
By comparing the *hqfeml* output with the original message, you can see the modifications:

```console
$ hqfeml -R 1 /var/spool/halon/queue/b1/b186d406-0c36-11ea-8dda-005056914940.hqf
```

<!-- standard link references -->
<!-- Standard link references for the queue_*.rst documents .. note schema versions will get updated on build -->
