/** * @return bool */ public function commitTransaction() { if (!$this->isInitialized()) { $this->initialize(); } return $this->channel->commitTransaction(); }
/** * @inheritdoc */ public function commitTransaction() { try { return $this->delegate->commitTransaction(); } catch (\AMQPChannelException $e) { throw new ChannelException($e->getMessage(), $e->getCode(), $e); } catch (\AMQPConnectionException $e) { throw new ConnectionException($e->getMessage(), $e->getCode(), $e); } }
/** * @return bool */ public function commitTransaction() { try { return $this->rawChannel->commitTransaction(); } catch (\Exception $e) { ClientHelper::throwRightException($e); } }
public function it_should_rollback_if_transaction_failed(\AMQPChannel $channel) { $channel->startTransaction()->shouldBeCalled(); $channel->commitTransaction()->shouldNotBeCalled(); $channel->rollbackTransaction()->shouldBeCalled(); $exception = new \Exception('Whhooops'); $process = function (Channel $channel) use($exception) { throw $exception; }; $this->shouldThrow(new HectorException('Transaction failed', 255, $exception))->during('transaction', [$process]); }
public function send($msg) { $channel = new \AMQPChannel($this->connection); $exchange = new \AMQPExchange($channel); $exchange->setFlags(AMQP_DURABLE); $exchange->setName('exchange2'); $exchange->setType('direct'); //$exchange->declare(); $exchange->declareExchange(); $queue = new \AMQPQueue($channel); $queue->setName('series'); $queue->setFlags(AMQP_DURABLE | AMQP_AUTODELETE); //$queue->declare(); $queue->declareQueue(); $queue->bind('exchange2', 'series'); $channel->startTransaction(); $message = $exchange->publish(json_encode($msg), 'series', AMQP_MANDATORY, array('content_type' => 'application/json', 'delivery_mode' => 2)); $channel->commitTransaction(); if (!$message) { throw new \SYSTEM\LOG\ERROR("Error: Message '" . $message . "' was not sent to queue.!"); } }
<?php require 'config.php'; $connection = new AMQPConnection($connect); $connection->connect(); $channel = new AMQPChannel($connection); $exchange = new AMQPExchange($channel); $exchange->setName($exname); $exchange->setType(AMQP_EX_TYPE_TOPIC); $exchange->setFlags(AMQP_DURABLE); $exchange->declare(); $queue = new AMQPQueue($channel); $queue->setName($qname); $queue->setFlags(AMQP_DURABLE); $queue->declare(); $queue->bind($exname, $routekey); $channel->startTransaction(); $message = json_encode(array('Hello World! 测试消息!', 'TOPIC')); $exchange->publish($message, $routekey); $channel->commitTransaction(); $connection->disconnect();
/** * @inheritdoc */ public function commitTransaction() { $this->channel->commitTransaction(); }
/** * {@inheritDoc} */ public function commit($key = null) { $this->channel->commitTransaction(); }