Nexus API Reference

MailboxConfig
in package

Read onlyYes
FinalYes

Immutable value object configuring the capacity and overflow behaviour of an actor mailbox.

Pass a MailboxConfig to Props::withMailbox() to tune how messages are queued for a specific actor. The default (unbounded) is suitable for most actors; use bounded mailboxes to apply back-pressure or drop policies on high-throughput pipelines.

Example:

// Drop the newest message when the mailbox is full (circuit-breaker pattern)
$props = Props::fromBehavior($behavior)
    ->withMailbox(MailboxConfig::bounded(100, OverflowStrategy::DropNewest));

// Unbounded queue — messages are never dropped (default)
$props = Props::fromBehavior($behavior)
    ->withMailbox(MailboxConfig::unbounded());
Tags
see
Props::withMailbox()

for attaching a config to an actor

OverflowStrategy

for the available overflow policies

Runtime::createMailbox()

for the runtime that instantiates the physical mailbox

psalm-api
psalm-immutable

Table of Contents

Properties

$bounded  : bool
$capacity  : int
$strategy  : OverflowStrategy

Methods

bounded()  : self
Create a bounded mailbox that enforces a maximum queue depth.
unbounded()  : self
Create an unbounded mailbox with no capacity limit.
withCapacity()  : self
Return a new config with the given capacity, preserving all other settings.
withStrategy()  : self
Return a new config with the given overflow strategy, preserving all other settings.

Properties

Methods

unbounded()

Create an unbounded mailbox with no capacity limit.

public static unbounded() : self

The queue grows without bound; only use this when message producers are naturally rate-limited or when unbounded memory growth is acceptable.

Return values
self

withCapacity()

Return a new config with the given capacity, preserving all other settings.

public withCapacity(int $capacity) : self
Parameters
$capacity : int
Return values
self
On this page

Search results