/** * Consumes a message. * * @param string $message * * @return string|null|void * * @throws \Exception */ public function consume($message) { try { $this->transactionManager->beginTransaction(); } catch (BeginException $e) { throw new ConsumerException($e->getMessage(), $e->getCode(), $e); } try { $this->consumer->consume($message); $this->transactionManager->commit(); } catch (\Exception $e) { $this->transactionManager->rollback(); throw $e; } }
function it_should_commit_on_the_sub_items(Transactional $item) { $item->beginTransaction()->shouldBeCalled(); $item->commit()->shouldBeCalled(); $this->addTransactionalItem($item); $this->beginTransaction(); $this->commit(); }
function it_should_not_commit_after_it_has_been_called_less_than_beginTransaction(Transactional $item) { $item->beginTransaction()->shouldBeCalledTimes(1); $item->commit()->shouldNotBeCalled(); $this->addTransactionalItem($item); $this->beginTransaction(); $this->beginTransaction(); $this->commit(); }