## Name

ActiveMQ Journal — stores messages in rolling log file for later processing

## Overview

The ActiveMQ Journal Component allows messages to be stored in a rolling log file and then consumed from that log file. The journal aggregates and batches up concurrent writes so that the overhead of writing and waiting for the disk sync is relatively constant, regardless of how many concurrent writes are being done. Therefore, this component supports and encourages you to use multiple concurrent producers to the same journal endpoint.

Each journal endpoint uses a different log file and therefore write batching (and the associated performance boost) does not occur between multiple endpoints.

This component only supports one active consumer on the endpoint. After the message is processed by the consumer's processor, the log file is marked and only subsequent messages in the log file will get delivered to consumers.

## URI format

The URI format for an ActiveMQ Journal endpoint is:

    activemq.journal:directoryName[?options]

`directoryName` specifies the name of the directory in which the journal is stored. For example, to send to a journal located in the `/tmp/data` directory you would use the following URI:

    activemq.journal:/tmp/data

## Options

Table 6, “ActiveMQ Journal optionss” lists the options available when using an ActiveMQ Journal endpoint.

Table 6. ActiveMQ Journal optionss

Name | Default Value | Description
--- | --- | ---
`syncConsume` | `false` | If set to `true`, when the journal is marked after a message is consumed, the endpoint wait until the operating system has verified the mark update is safely stored on disk.
`syncProduce` | `true` | If set to `true`, wait until the operating system has verified the message is safely stored on disk.

## Expected Exchange Data Types

The consumer of a Journal endpoint generates `DefaultExchange` objects with the In message set as follows:

- `journal` header: set to the endpoint URI of the journal the message came from.

- `location` header: location: set to a `Location` object which identifies where the recored was stored on disk.

- Message body: set to a `ByteSequence`, which contains the byte array data of the stored message.

The producer to a Journal endpoint expects an exchange with an In message where the body can be converted to a `ByteSequence` or a `byte[]`.