1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# AMQPMessage #
## Message Durability ##
When creating a new message set the `delivery_mode` to `AMQPMessage::DELIVERY_MODE_PERSISTENT`:
$msg = new AMQPMessage(
$msg_body,
array(
'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT
)
);
## Supported message properties ##
"content_type" => "shortstr",
"content_encoding" => "shortstr",
"application_headers" => "table",
"delivery_mode" => "octet",
"priority" => "octet",
"correlation_id" => "shortstr",
"reply_to" => "shortstr",
"expiration" => "shortstr",
"message_id" => "shortstr",
"timestamp" => "timestamp",
"type" => "shortstr",
"user_id" => "shortstr",
"app_id" => "shortstr",
"cluster_id" => "shortst"
Getting message properties:
$msg->get('correlation_id');
$msg->get('delivery_mode');
## Acknowledging messages ##
You can acknowledge messages by sending a `basic_ack` on the channel:
$msg->getChannel()->
basic_ack($msg->getDeliveryTag());
Or by sending `ack` method on the message:
$msg->ack();
Keep in mind that the `delivery_tag` has to be valid so most of the time just use the one provide by the server.
If you don't want to access the `delivery_info` array directly you can also use `$msg->get('delivery_tag')` but keep in mind that's slower than just accessing the array by key.
## What's on the delivery info? ##
When RabbitMQ delivers a message the library will add the following `delivery_info` to the message:
$delivery_info = array(
"channel" => $this,
"consumer_tag" => $consumer_tag,
"delivery_tag" => $delivery_tag,
"redelivered" => $redelivered,
"exchange" => $exchange,
"routing_key" => $routing_key
);
They can also be accessed using the AMQPMessage::get function:
$msg->get('channel');
|