# Outbox

## Dependencies

Valtimo contains an implementation of the [transactional outbox pattern](https://microservices.io/patterns/data/transactional-outbox.html). To make use of this pattern, the `outbox` module needs to be added as a dependency. The following can be added to your project, depending on whether Maven or Gradle is used:

### Backend

The samples below assume the [valtimo-dependency-versions](/v12/fundamentals/getting-started/modules/core/valtimo-dependency-versions.md) module is used. If not, please specify the artifact version as well.

#### Maven dependency:

```xml

<dependencies>
  <dependency>
    <groupId>com.ritense.valtimo</groupId>
    <artifactId>outbox</artifactId>
    <version>${valtimo_version}</version>
  </dependency>
</dependencies>
```

#### Gradle dependency:

```kotlin
dependencies {
    implementation("com.ritense.valtimo:outbox")
}
```

## Configuration

The outbox can be configured to better match the environment:

#### **`application.yml`**

```yaml
valtimo:
  outbox:
    publisher:
      polling:
        rate: "PT1M" # ISO 8601 duration format. Default: PT10S
        batch-size: 10 # Number of messages to fetch and publish per poll cycle
        circuit-breaker:
          enabled: true # Enable/disable the circuit breaker
          failure-rate-threshold: 50 # Percentage of failures that triggers the circuit to open
          minimum-number-of-calls: 5 # Minimum calls before failure rate is evaluated
          sliding-window-size: 10 # Number of calls tracked for failure rate calculation
          wait-duration-in-open-state-seconds: 60 # How long the circuit stays open
          permitted-number-of-calls-in-half-open-state: 3 # Test calls allowed in half-open state
```

### Disabling the outbox

It is possible to disable the outbox functionality without having to remove the module. This is useful for environments where you might not want the overhead this module adds.\
When disabled, a no-operation `OutboxService` implementation bean will be used. This will be the only `outbox` bean available to the application.

The outbox will be disabled by setting the following application property:

```yaml
valtimo.outbox.enabled: false
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.valtimo.nl/v12/fundamentals/getting-started/modules/core/outbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
