Sending a message can specify some parameters for the message
- Delivery mode: Whether to persist, 1-Non-persistent, 2-Persistent
- Headers:Headers can have any name. Only long string headers can be set here.
- Properties: You can set other message properties here (delivery mode and headers are pulled out as the most common cases). Invalid properties will be ignored. Valid properties are:
- content_type: the type of message content
- content_encoding: the encoding format of the message content
- priority: the priority of the message
- correlation_id: correlation id
- reply_to: The name of the queue used to specify the reply
- expiration: the expiration time of the message
- message_id: message id
- timestamp: the timestamp of the message
- type: Type
- user_id: user id
- app_id: application id
- cluster_id: cluster id
- Payload: message content
E.g:
Add message_id when producing a message:
$message = new AMQPMessage($messageBody, ['content_type' => 'text/plain','message_id'=>123, 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]); // 定义消息
When consuming news:
if($msg->has('message_id')){
echo_txt(' >>> message_id '. $msg->get('message_id'). "\n");
}