-
Notifications
You must be signed in to change notification settings - Fork 465
Recreate channel after reconnect. Message confirmation feature #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
36cafbc
Fixed issue with reconnect and not existing channels
dbalabka 4d5fbbb
Added additional alise for fix
dbalabka aac0c2d
Added additional alise for fix
dbalabka 72e93bd
Added replace into composer.json
dbalabka 8c7ecc2
Remove changes from composer json
dbalabka b3ad3f9
Rollback changes to composer json
dbalabka f66fc27
Merge remote-tracking branch 'upstream/master' into reconnect-fix-ups…
dbalabka 68d9f1f
Fixed dev branch name
dbalabka e73698b
Fixed tests. Rollback changes in composer
dbalabka 6842474
Fixed tests
dbalabka 227e305
Added one line
dbalabka 693ba5a
Merge remote-tracking branch 'upstream/master' into reconnect-fix-ups…
dbalabka 86c3937
Merge remote-tracking branch 'upstream/master' into reconnect-fix-ups…
dbalabka 9cde59c
Added minimum required php-amqplib
dbalabka 7b94fd5
Updated with accordance of php-amqplib 2.6.3 changes
dbalabka 1a1b63c
Fixed composer deps. Added test cases. Removed fix.
dbalabka 6a97fde
Fixed test for unsupported PHP versions
dbalabka 70243ca
Fixed test for unsupported PHP versions
dbalabka 15af878
Rollback reconnect fix
dbalabka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace OldSound\RabbitMqBundle\Tests\RabbitMq; | ||
|
||
use OldSound\RabbitMqBundle\RabbitMq\Producer; | ||
|
||
class ProducerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testReconnect() | ||
{ | ||
$connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); | ||
$channel = $this->prophesize('\PhpAmqpLib\Channel\AMQPChannel'); | ||
$producer = new Producer($connection->reveal()); | ||
|
||
$connection->isConnected()->willReturn(true); | ||
$connection->reconnect()->shouldBeCalled(); | ||
$connection->close()->shouldBeCalled(); | ||
$connection->channel()->willReturn($channel->reveal()); | ||
|
||
$producer->reconnect(); | ||
$producer->getChannel(); | ||
} | ||
|
||
public function testEnableConfirmationWhenChannelIsNotSet() | ||
{ | ||
$connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); | ||
$channel = $this->prophesize('\PhpAmqpLib\Channel\AMQPChannel'); | ||
$producer = new Producer($connection->reveal()); | ||
|
||
$channel->close()->shouldBeCalled(); | ||
$channel->confirm_select()->shouldBeCalled(); | ||
|
||
$producer->enableConfirmation(); | ||
$producer->setChannel($channel->reveal()); | ||
} | ||
|
||
public function testEnableConfirmationWhenChannelIsSet() | ||
{ | ||
$connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); | ||
$channel = $this->prophesize('\PhpAmqpLib\Channel\AMQPChannel'); | ||
$producer = new Producer($connection->reveal()); | ||
|
||
$channel->close()->shouldBeCalled(); | ||
$channel->confirm_select()->shouldBeCalled(); | ||
|
||
$producer->setChannel($channel->reveal()); | ||
$producer->enableConfirmation(); | ||
} | ||
|
||
public function testWaitConfirmation() | ||
{ | ||
$connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); | ||
$channel = $this->prophesize('\PhpAmqpLib\Channel\AMQPChannel'); | ||
|
||
$producer = new Producer($connection->reveal()); | ||
|
||
$channel->close()->shouldBeCalled(); | ||
$channel->confirm_select()->shouldBeCalled(); | ||
$channel->getChannelId()->willReturn('channel_id'); | ||
$channel->wait_for_pending_acks($producer->getWaitConfirmationTimeout())->shouldBeCalled(); | ||
|
||
$producer->setChannel($channel->reveal()); | ||
$producer->enableConfirmation(); | ||
$producer->waitConfirmation(); | ||
} | ||
|
||
/** | ||
* @dataProvider provideTestSetWaitConfirmationTimeout | ||
*/ | ||
public function testSetWaitConfirmationTimeout($timeout, $expectedException) | ||
{ | ||
$connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); | ||
|
||
$producer = new Producer($connection->reveal()); | ||
|
||
try { | ||
$producer->setWaitConfirmationTimeout($timeout); | ||
$this->assertEquals($timeout, $producer->getWaitConfirmationTimeout()); | ||
} catch (\InvalidArgumentException $e) { | ||
if ($expectedException) { | ||
$this->addToAssertionCount(1); | ||
} | ||
} | ||
} | ||
|
||
public function provideTestSetWaitConfirmationTimeout() | ||
{ | ||
return array( | ||
'correct timeout' => array( | ||
'timeout' => 5, | ||
'expectedException' => false, | ||
), | ||
'timeout zero' => array( | ||
'timeout' => 0, | ||
'expectedException' => false, | ||
), | ||
'timeout less then zero' => array( | ||
'timeout' => -1, | ||
'expectedException' => '\InvalidArgumentException', | ||
), | ||
'timeout not integer' => array( | ||
'timeout' => '5', | ||
'expectedException' => '\InvalidArgumentException', | ||
), | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
"symfony/config": "~2.3 || ~3.0", | ||
"symfony/yaml": "~2.3 || ~3.0", | ||
"symfony/console": "~2.3 || ~3.0", | ||
"php-amqplib/php-amqplib": "~2.6", | ||
"php-amqplib/php-amqplib": "^2.6.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconnect fix doesn't work even in 2.7 Note that originaly I have assumed that following PRs must be merged, but it is still not enought. |
||
"psr/log": "~1.0" | ||
}, | ||
"require-dev": { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stloyd not sure why this condition need to be changed. Please explain.
I have added few test cases for this this method test. By changing this condition, as you propose, it lead to two test cases fail:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stloyd ping