This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.3.

# Pidbox - `kombu.pidbox`

Generic process mailbox.

## Introduction

### Creating the applications Mailbox

    >>> mailbox = pidbox.Mailbox('celerybeat', type='direct')

    >>> @mailbox.handler
    >>> def reload_schedule(state, **kwargs):
    ...     state['beat'].reload_schedule()

    >>> @mailbox.handler
    >>> def connection_info(state, **kwargs):
    ...     return {'connection': state['connection'].info()}

### Example Node

    >>> connection = kombu.Connection()
    >>> state = {'beat': beat,
                 'connection': connection}
    >>> consumer = mailbox(connection).Node(hostname).listen()
    >>> try:
    ...     while True:
    ...         connection.drain_events(timeout=1)
    ... finally:
    ...     consumer.cancel()

### Example Client

    >>> mailbox.cast('reload_schedule')   # cast is async.
    >>> info = celerybeat.call('connection_info', timeout=1)

## Mailbox

class kombu.pidbox.Mailbox(namespace, type='direct', connection=None, clock=None, accept=None, serializer=None, producer_pool=None, queue_ttl=None, queue_expires=None, queue_durable=False, queue_exclusive=False, reply_queue_ttl=None, reply_queue_expires=10.0)

  Process Mailbox.

  namespace = None

    Name of application.

  connection = None

    Connection (if bound).

  type = 'direct'

    Exchange type (usually direct, or fanout for broadcast).

  exchange = None

    mailbox exchange (init by constructor).

  reply_exchange = None

    exchange to send replies to.

  Node(hostname=None, state=None, channel=None, handlers=None)
  call(destination, command, kwargs=None, timeout=None, callback=None, channel=None)
  cast(destination, command, kwargs=None)
  abcast(command, kwargs=None)
  multi_call(command, kwargs=None, timeout=1, limit=None, callback=None, channel=None)
  get_reply_queue()
  get_queue(hostname)

### Mailbox Options

Added in version 5.6.0.

The Mailbox supports several configuration options that affect the behavior of its exchanges and queues.

- `durable`: If True, declares durable exchanges that survive broker restarts.

- `exclusive`: If True, declares exclusive exchanges (usable by only one connection).

These provide finer control over broker-side behavior and are useful in production environments where queue durability matters.

## Node

class kombu.pidbox.Node(hostname, state=None, channel=None, handlers=None, mailbox=None)

  Mailbox node.

  hostname = None

    hostname of the node.

  mailbox = None

    the `Mailbox` this is a node for.

  handlers = None

    map of method name/handlers.

  state = None

    current context (passed on to handlers)

  channel = None

    current channel.

  Consumer(channel=None, no_ack=True, accept=None, **options)
  handler(fun)
  listen(channel=None, callback=None)
  dispatch(method, arguments=None, reply_to=None, ticket=None, **kwargs)
  dispatch_from_message(body, message=None)
  handle_call(method, arguments)
  handle_cast(method, arguments)
  handle(method, arguments=None)
  handle_message(body, message=None)
  reply(data, exchange, routing_key, ticket, **kwargs)