startTransaction() 공개 메소드

This method must be called on the given channel prior to calling AMQPChannel::commitTransaction() or AMQPChannel::rollbackTransaction().
public startTransaction ( ) : boolean
리턴 boolean TRUE on success or FALSE on failure.
예제 #1
0
파일: Channel.php 프로젝트: Evaneos/Hector
 /**
  * @return bool
  */
 public function startTransaction()
 {
     if (!$this->isInitialized()) {
         $this->initialize();
     }
     return $this->channel->startTransaction();
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function startTransaction()
 {
     try {
         return $this->delegate->startTransaction();
     } catch (\AMQPChannelException $e) {
         throw new ChannelException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPConnectionException $e) {
         throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
     }
 }
예제 #3
0
 /**
  * @return bool
  */
 public function startTransaction()
 {
     try {
         return $this->rawChannel->startTransaction();
     } catch (\AMQPConnectionException $e) {
         ClientHelper::throwRightException($e);
     }
 }
예제 #4
0
 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]);
 }
예제 #5
0
 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.!");
     }
 }
예제 #6
0
<?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();
예제 #7
0
 /**
  * @inheritdoc
  */
 public function startTransaction()
 {
     $this->channel->startTransaction();
 }
예제 #8
0
 /**
  * {@inheritDoc}
  */
 public function begin($key = null, array $options = [])
 {
     $this->channel->startTransaction();
 }