This document describes the current stable version of Kombu (4.5). For development docs, go here.

Virtual AMQ Exchange Implementation - kombu.transport.virtual.exchange

Virtual AMQ Exchange.

Implementations of the standard exchanges defined by the AMQ protocol (excluding the headers exchange).

Direct

class kombu.transport.virtual.exchange.DirectExchange(channel)[source]

Direct exchange.

The direct exchange routes based on exact routing keys.

deliver(message, exchange, routing_key, **kwargs)[source]
lookup(table, exchange, routing_key, default)[source]

Lookup all queues matching routing_key in exchange.

Returns:queue name, or ‘default’ if no queues matched.
Return type:str
type = 'direct'

Topic

class kombu.transport.virtual.exchange.TopicExchange(channel)[source]

Topic exchange.

The topic exchange routes messages based on words separated by dots, using wildcard characters * (any single word), and # (one or more words).

deliver(message, exchange, routing_key, **kwargs)[source]
key_to_pattern(rkey)[source]

Get the corresponding regex for any routing key.

lookup(table, exchange, routing_key, default)[source]

Lookup all queues matching routing_key in exchange.

Returns:queue name, or ‘default’ if no queues matched.
Return type:str
prepare_bind(queue, exchange, routing_key, arguments)[source]

Prepare queue-binding.

Returns:
of (routing_key, regex, queue)
to be stored for bindings to this exchange.
Return type:Tuple[str, Pattern, str]
type = 'topic'
wildcards = {'#': '.*?', '*': '.*?[^\\.]'}

map of wildcard to regex conversions

Fanout

class kombu.transport.virtual.exchange.FanoutExchange(channel)[source]

Fanout exchange.

The fanout exchange implements broadcast messaging by delivering copies of all messages to all queues bound to the exchange.

To support fanout the virtual channel needs to store the table as shared state. This requires that the Channel.supports_fanout attribute is set to true, and the Channel._queue_bind and Channel.get_table methods are implemented.

See also

the redis backend for an example implementation of these methods.

deliver(message, exchange, routing_key, **kwargs)[source]
lookup(table, exchange, routing_key, default)[source]

Lookup all queues matching routing_key in exchange.

Returns:queue name, or ‘default’ if no queues matched.
Return type:str
type = 'fanout'

Interface

class kombu.transport.virtual.exchange.ExchangeType(channel)[source]

Base class for exchanges.

Implements the specifics for an exchange type.

Parameters:channel (ChannelT) – AMQ Channel.
equivalent(prev, exchange, type, durable, auto_delete, arguments)[source]

Return true if prev and exchange is equivalent.

lookup(table, exchange, routing_key, default)[source]

Lookup all queues matching routing_key in exchange.

Returns:queue name, or ‘default’ if no queues matched.
Return type:str
prepare_bind(queue, exchange, routing_key, arguments)[source]

Prepare queue-binding.

Returns:
of (routing_key, regex, queue)
to be stored for bindings to this exchange.
Return type:Tuple[str, Pattern, str]
type = None