PHP Australia Conference 2015

AMQPExchange::publish

(PECL amqp >= Unknown)

AMQPExchange::publishPublish a message to an exchange.

Descrição

public bool AMQPExchange::publish ( string $message , string $routing_key [, int $flags = AMQP_NOPARAM [, array $attributes = array() ]] )

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

Parâmetros

message

The message to publish.

routing_key

The routing key to which to publish.

flags

One or more of AMQP_MANDATORY and AMQP_IMMEDIATE.

attributes

Supported indexes
key Description Default value
content_type   text/plain
content_encoding   NULL
message_id   NULL
user_id   NULL
app_id   NULL
delivery_mode   NULL
priority   NULL
timestamp   NULL
expiration time in milliseconds NULL
type   NULL
reply_to   NULL
headers custom attributes to pass along with message array

Valor Retornado

Retorna TRUE em caso de sucesso ou FALSE em caso de falha.

Erros

Throws an AMQPExchangeException on failure.

Throws AMQPChannelException if the channel is not open.

Throws AMQPConnectionException if the connection to the broker was lost.

add a note add a note

User Contributed Notes 3 notes

up
1
zircote
2 years ago
additional attribute to the publish method is

`correlation_id`
up
0
Andy (Larest)
1 year ago
to send custom headers, you need send it as associative array under attribute 'headers'
up
0
glenjamin at gmail dot com
2 years ago
Any unused attributes will be assigned as custom headers attached to the outgoing message's headers collection.

This isn't exactly clear from the documentation above, but I've checked the C source, and that's how you set custom headers.
To Top