Skip to content

Commit

Permalink
Merge pull request #2 from remi-san/burrow4
Browse files Browse the repository at this point in the history
Compatibility with burrow-v4
  • Loading branch information
remi-san authored Jan 11, 2017
2 parents 948cbb5 + 2f09434 commit ebead91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"henrikbjorn/phpspec-code-coverage": "^2.0",
"doctrine/dbal": "^2.5",
"doctrine/orm": "^2.5",
"evaneos/burrow": "^3.0",
"evaneos/burrow": "^4.0",
"league/event": "^2.1",
"league/tactician": "^1.0"
},
Expand Down
5 changes: 3 additions & 2 deletions src/Amqp/TransactionalQueuePublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(QueuePublisher $publisher)
/**
* {@inheritdoc}
*/
public function publish($data, $routingKey = '')
public function publish($data, $routingKey = '', array $headers = [])
{
if (!$this->running) {
throw new TransactionException('Cannot publish outside a transaction');
Expand All @@ -41,6 +41,7 @@ public function publish($data, $routingKey = '')
$this->messages[] = [
'data' => $data,
'routingKey' => $routingKey,
'headers' => $headers
];
}

Expand All @@ -58,7 +59,7 @@ public function beginTransaction()
public function commit()
{
foreach ($this->messages as $message) {
$this->publisher->publish($message['data'], $message['routingKey']);
$this->publisher->publish($message['data'], $message['routingKey'], $message['headers']);
}
$this->messages = [];
$this->running = false;
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/Amqp/TransactionalQueuePublisherSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function it_is_not_possible_to_publish_outside_a_transaction()
function it_should_publish_message_when_committing(QueuePublisher $publisher)
{
$this->beginTransaction();
$publisher->publish('', '')->shouldBeCalled();
$publisher->publish('', '', [])->shouldBeCalled();
$this->publish('', '');
$this->commit();
}

function it_should_not_publish_message_when_rollbacking(QueuePublisher $publisher)
{
$this->beginTransaction();
$publisher->publish('', '')->shouldNotBeCalled();
$publisher->publish('', '', [])->shouldNotBeCalled();
$this->publish('', '');
$this->rollback();
}
Expand Down

0 comments on commit ebead91

Please sign in to comment.