class AMQPExchange (View source)

stub class representing AMQPExchange from pecl-amqp

Methods

__construct(AMQPChannel $channel)

Create an instance of AMQPExchange.

void
bind(string $exchangeName, string $routingKey = '', array $arguments = [])

Bind to another exchange.

void
unbind(string $exchangeName, string $routingKey = '', array $arguments = [])

Remove binding to another exchange.

void
declareExchange()

Declare a new exchange on the broker.

void
declare()

Declare a new exchange on the broker.

void
delete(string $exchangeName = null, int $flags = AMQP_NOPARAM)

Delete the exchange from the broker.

bool|int|float|string|null
getArgument(string $argumentName)

Get the argument associated with the given key.

bool
hasArgument(string $argumentName)

Check whether argument associated with the given key exists.

array
getArguments()

Get all arguments set on the given exchange.

int
getFlags()

Get all the flags currently set on the given exchange.

string|null
getName()

Get the configured name.

string|null
getType()

Get the configured type.

void
publish(string $message, string|null $routingKey = null, int|null $flags = null, array $headers = [])

Publish a message to an exchange.

void
setArgument(string $argumentName, string|int $argumentValue)

Set the value for the given key.

void
removeArgument(string $argumentName)

Set the value for the given key.

bool
setArguments(array $arguments)

Set all arguments on the exchange.

void
setFlags(int|null $flags)

Set the flags on an exchange.

void
setName(string $exchangeName)

Set the name of the exchange.

void
setType(string $exchangeType)

Set the type of the exchange.

getChannel()

Get the AMQPChannel object in use

getConnection()

Get the AMQPConnection object in use

Details

__construct(AMQPChannel $channel)

Create an instance of AMQPExchange.

Returns a new instance of an AMQPExchange object, associated with the given AMQPChannel object.

Parameters

AMQPChannel $channel

A valid AMQPChannel object, connected to a broker.

Exceptions

AMQPExchangeException
AMQPConnectionException

void bind(string $exchangeName, string $routingKey = '', array $arguments = [])

Bind to another exchange.

Bind an exchange to another exchange using the specified routing key.

Parameters

string $exchangeName

Name of the exchange to bind.

string $routingKey

The routing key to use for binding.

array $arguments

Additional binding arguments.

Return Value

void

Exceptions

AMQPExchangeException
AMQPChannelException
AMQPConnectionException

void unbind(string $exchangeName, string $routingKey = '', array $arguments = [])

Remove binding to another exchange.

Remove a routing key binding on an another exchange from the given exchange.

Parameters

string $exchangeName

Name of the exchange to bind.

string $routingKey

The routing key to use for binding.

array $arguments

Additional binding arguments.

Return Value

void

Exceptions

AMQPExchangeException
AMQPChannelException
AMQPConnectionException

void declareExchange()

Declare a new exchange on the broker.

void declare()

Declare a new exchange on the broker.

void delete(string $exchangeName = null, int $flags = AMQP_NOPARAM)

Delete the exchange from the broker.

Parameters

string $exchangeName

Optional name of exchange to delete.

int $flags

Optionally AMQP_IFUNUSED can be specified to indicate the exchange should not be deleted until no clients are connected to it.

Return Value

void

Exceptions

AMQPExchangeException
AMQPChannelException
AMQPConnectionException

bool|int|float|string|null getArgument(string $argumentName)

Get the argument associated with the given key.

Get the argument associated with the given key.

Parameters

string $argumentName

The key to look up.

Return Value

bool|int|float|string|null

Exceptions

AMQPExchangeException

bool hasArgument(string $argumentName)

Check whether argument associated with the given key exists.

Parameters

string $argumentName

The key to look up.

Return Value

bool

array getArguments()

Get all arguments set on the given exchange.

Return Value

array

An array containing all of the set key/value pairs.

int getFlags()

Get all the flags currently set on the given exchange.

Return Value

int

An integer bitmask of all the flags currently set on this exchange object.

string|null getName()

Get the configured name.

Return Value

string|null

The configured name as a string.

string|null getType()

Get the configured type.

Return Value

string|null

The configured type as a string.

void publish(string $message, string|null $routingKey = null, int|null $flags = null, array $headers = [])

Publish a message to an exchange.

Publish a message to the exchange represented by the AMQPExchange object.

Parameters

string $message

The message to publish.

string|null $routingKey

The optional routing key to which to publish to.

int|null $flags

One or more of AMQP_MANDATORY and AMQP_IMMEDIATE.

array $headers

One of content_type, content_encoding, message_id, user_id, app_id, delivery_mode, priority, timestamp, expiration, type or reply_to, headers.

Return Value

void

Exceptions

AMQPExchangeException
AMQPChannelException
AMQPConnectionException

void setArgument(string $argumentName, string|int $argumentValue)

Set the value for the given key.

Parameters

string $argumentName

Name of the argument to set.

string|int $argumentValue

Value of the argument to set.

Return Value

void

void removeArgument(string $argumentName)

Set the value for the given key.

Parameters

string $argumentName

Name of the argument to remove.

Return Value

void

bool setArguments(array $arguments)

Set all arguments on the exchange.

Parameters

array $arguments

An array of key/value pairs of arguments.

Return Value

bool

TRUE on success or FALSE on failure.

void setFlags(int|null $flags)

Set the flags on an exchange.

Parameters

int|null $flags

A bitmask of flags. This call currently only considers the following flags: AMQP_DURABLE, AMQP_PASSIVE (and AMQP_DURABLE, if librabbitmq version >= 0.5.3)

Return Value

void

void setName(string $exchangeName)

Set the name of the exchange.

Parameters

string $exchangeName

The name of the exchange to set as string.

Return Value

void

void setType(string $exchangeType)

Set the type of the exchange.

Set the type of the exchange. This can be any of AMQP_EX_TYPE_DIRECT, AMQP_EX_TYPE_FANOUT, AMQP_EX_TYPE_HEADERS or AMQP_EX_TYPE_TOPIC.

Parameters

string $exchangeType

The type of exchange as a string.

Return Value

void

AMQPChannel getChannel()

Get the AMQPChannel object in use

Return Value

AMQPChannel

AMQPConnection getConnection()

Get the AMQPConnection object in use

Return Value

AMQPConnection