共计 618 个字符,预计需要花费 2 分钟才能阅读完成。
普通发送:
$ex->publish($message, $this->_queue->getName(), AMQP_MANDATORY, $params);
事务模式:
单个发送:
$ch->startTransaction();
try {$ex->publish($message, $this->_queue->getName(), AMQP_MANDATORY, $params);
$ch->commitTransaction();}
catch(AMQPConnectionException $e) {$ch->rollbackTransaction();
}
批量发送:
$loop_times = 10;
$ch->startTransaction();
for($i=0;$i<$loop_times;$i++) {
try {$ex->publish($message, $this->_queue->getName(), AMQP_MANDATORY, $params);
$ch->commitTransaction();}
catch(AMQPConnectionException $e) {$ch->rollbackTransaction();
}
}
// to be continued
Refer:
RabbitMQ 专栏:https://blog.csdn.net/u013256…
php-amqp 测试用例:https://github.com/pdezwart/p…
正文完
发表至: rabbitMq
2019-06-17