(PECL amqp >= Unknown)
AMQPExchange::publish — Publish a message to an exchange.
$message
, string $routing_key
[, int $flags
= AMQP_NOPARAM
[, array $attributes
= array()
]] )Publish a message to the exchange represented by the AMQPExchange object.
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
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 | NULL | |
type | NULL | |
reply_to | NULL |
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
Throws an AMQPExchangeException on failure.
Throws AMQPChannelException if the channel is not open.
Throws AMQPConnectionException if the connection to the broker was lost.
Andy (Larest) (2012-12-07 17:06:44)
to send custom headers, you need send it as associative array under attribute 'headers'
zircote (2012-04-18 15:45:54)
additional attribute to the publish method is
`correlation_id`
glenjamin at gmail dot com (2012-02-19 20:27:51)
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.