> For the complete documentation index, see [llms.txt](https://brightercommand.gitbook.io/paramore-brighter-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brightercommand.gitbook.io/paramore-brighter-documentation/outbox-and-inbox/brighterinboxsupport/inmemoryinbox.md).

# InMemory Inbox

The in-process Inbox: when to use it, how to configure it, and its limits.

> **Reference** · Applies to **Brighter V10** · Prerequisites: [InMemory Options for Development and Testing](/paramore-brighter-documentation/brighter-configuration/inmemoryoptions.md)

The in-process Inbox: when to use it, how to configure it, and its limits. It is part of Brighter's [InMemory options for development and testing](/paramore-brighter-documentation/brighter-configuration/inmemoryoptions.md).

The InMemory Inbox provides message deduplication without requiring a database.

## When to Use the InMemory Inbox

**Perfect for**:

* Unit testing duplicate message handling
* Development without database dependencies

**Production Use Cases** (limited):

* Single-process applications
* Short-lived message deduplication windows
* Non-critical deduplication scenarios

## InMemory Inbox Configuration

```csharp
// ...
var bus = new InternalBus();

services.AddConsumers(options =>
{
    options.HandlerLifetime = ServiceLifetime.Scoped;
    options.InboxConfiguration = new InboxConfiguration(
        new InMemoryInbox(TimeProvider.System),
        actionOnExists: OnceOnlyAction.Warn
    );
    options.Subscriptions = subscriptions;
    options.DefaultChannelFactory = new InMemoryChannelFactory(bus, TimeProvider.System);
})
.AutoFromAssemblies();
```

## InMemory Inbox Example Usage

```csharp
// ...
[UseInboxAsync(step: 0, contextKey: typeof(PersonCreatedHandler), onceOnly: true)]
public class PersonCreatedHandler : RequestHandlerAsync<PersonCreated>
{
    private readonly PersonRepository _repository;

    [UseInboxAsync(0, typeof(PersonCreatedHandler), true)]
    public override async Task<PersonCreated> HandleAsync(
        PersonCreated @event,
        CancellationToken cancellationToken = default)
    {
        // Inbox ensures this handler processes each message only once
        var person = await _repository.GetByIdAsync(@event.PersonId);
        person.MarkAsCreated();
        await _repository.SaveAsync(person);

        return await base.HandleAsync(@event, cancellationToken);
    }
}
```

## InMemory Inbox Limitations

* **No persistence**: Deduplication state lost on restart
* **Single process**: Cannot deduplicate across instances
* **Memory bound**: All seen message IDs held in memory
* **No cleanup**: Old entries remain until process restart

## Further Reading

* [InMemory Options for Development and Testing](/paramore-brighter-documentation/brighter-configuration/inmemoryoptions.md) - The full set, and testing patterns


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://brightercommand.gitbook.io/paramore-brighter-documentation/outbox-and-inbox/brighterinboxsupport/inmemoryinbox.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
