乐趣区

RabbitMQ笔记

普通发送:

$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…

退出移动版