From 36cafbcbee5891df3b9aaef49b805a852fc166f8 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 23 May 2016 15:21:05 +0300 Subject: [PATCH 01/16] Fixed issue with reconnect and not existing channels --- RabbitMq/BaseAmqp.php | 110 +++++++++++++++++++++++++++++++- Tests/RabbitMq/ProducerTest.php | 84 ++++++++++++++++++++++++ 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 Tests/RabbitMq/ProducerTest.php diff --git a/RabbitMq/BaseAmqp.php b/RabbitMq/BaseAmqp.php index 7c9c8e2a..9d41df2a 100644 --- a/RabbitMq/BaseAmqp.php +++ b/RabbitMq/BaseAmqp.php @@ -16,6 +16,19 @@ abstract class BaseAmqp protected $autoSetupFabric = true; protected $basicProperties = array('content_type' => 'text/plain', 'delivery_mode' => 2); + /** + * Initialize confirmation mechanism for channel if enabled. + * See RabbitMQ {@link https://www.rabbitmq.com/confirms.html documentation} + * + * @var bool + */ + protected $enableConfirmation = false; + + /** + * @var int + */ + private $waitConfirmationTimeout = 1; + protected $exchangeOptions = array( 'passive' => false, 'durable' => true, @@ -72,6 +85,13 @@ public function reconnect() return; } + /** + * TODO: must be done with one reconnect when php-amqplib will be updated till 2.6.3 + * see https://github.com/php-amqplib/php-amqplib/commit/2ccc97ca5b1229f9b12ea47fbab6c16fad26df41 + * see https://github.com/php-amqplib/php-amqplib/commit/c87469ecbbf38fdc18688d3216c1e253d640ba32 + */ + $this->conn->reconnect(); + $this->closeChannel(); $this->conn->reconnect(); } @@ -81,7 +101,7 @@ public function reconnect() public function getChannel() { if (empty($this->ch)) { - $this->ch = $this->conn->channel(); + $this->setChannel($this->conn->channel()); } return $this->ch; @@ -94,6 +114,7 @@ public function getChannel() public function setChannel(AMQPChannel $ch) { $this->ch = $ch; + $this->initChannel(); } /** @@ -187,4 +208,91 @@ public function setupFabric() public function disableAutoSetupFabric() { $this->autoSetupFabric = false; } + + /** + * Close assigned channel + * + * @return void + */ + protected function closeChannel() + { + if (!$this->ch) { + return; + } + try { + $this->ch = null; + } catch (\Exception $e) { + // ignore exception on Channel object destructor + // TODO: this workaround can be removed after php-amqplib will be updated till 2.6.3 + } + } + + /** + * Wait for channel confirms that message is delivered after publish + * + * @return void + */ + public function waitConfirmation() + { + $this->getChannel()->wait_for_pending_acks($this->waitConfirmationTimeout); + } + + /** + * Set publish confirmation timeout + * + * @param int $timeout in seconds or 0 to wait forever + * + * @return void + * @throws \InvalidArgumentException if provided timeout isn't a integer or less than zero + */ + public function setWaitConfirmationTimeout($timeout) + { + if (!is_int($timeout) || $timeout < 0) { + throw new \InvalidArgumentException('Confirmation timeout must be an integer and greater or equal to zero'); + } + $this->waitConfirmationTimeout = $timeout; + } + + /** + * Return timeout in seconds + * + * @return int + */ + public function getWaitConfirmationTimeout() + { + return $this->waitConfirmationTimeout; + } + + /** + * Enable channel confirmation + * + * @return void + */ + public function enableConfirmation() + { + if ($this->enableConfirmation) { + // already enabled so we are sure that channel already properly initialized + return; + } + + $this->enableConfirmation = true; + + // If channel already created need to reinitialize it + if ($this->ch) { + $this->initChannel(); + } + } + + /** + * Initialize channel setting(e.g. confirmation) + * + * @return void + */ + protected function initChannel() + { + if ($this->enableConfirmation) { + $this->ch->confirm_select(); + } + } + } diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php new file mode 100644 index 00000000..08b6c1ca --- /dev/null +++ b/Tests/RabbitMq/ProducerTest.php @@ -0,0 +1,84 @@ +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->wait_for_pending_acks($producer->getWaitConfirmationTimeout())->shouldBeCalled(); + + $producer->setChannel($channel->reveal()); + $producer->enableConfirmation(); + $producer->waitConfirmation(); + } + + public function testSetWaitConfirmationTimeout() + { + $connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); + + $producer = new Producer($connection->reveal()); + $producer->setWaitConfirmationTimeout(5); + $this->assertEquals(5, $producer->getWaitConfirmationTimeout()); + } +} \ No newline at end of file From 4d5fbbbc4850fed7ff40b9c9094c98cd719b022a Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 30 May 2016 15:30:29 +0300 Subject: [PATCH 02/16] Added additional alise for fix --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a3a44330..138fd426 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.2.x-dev", + "dev-reconnect-fix": "1.2.x-dev" } }, "autoload": { From aac0c2d46015ef5ae31548e4c0b28ea53f71f428 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 30 May 2016 19:35:20 +0300 Subject: [PATCH 03/16] Added additional alise for fix --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 138fd426..bcf9e8a4 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "extra": { "branch-alias": { "dev-master": "1.2.x-dev", - "dev-reconnect-fix": "1.2.x-dev" + "dev-reconnect-fix": "1.6.x-dev" } }, "autoload": { From 72e93bd89e3ad7401dcc9c9dea9901b563636ec4 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 30 May 2016 20:30:37 +0300 Subject: [PATCH 04/16] Added replace into composer.json --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bcf9e8a4..ae9aa4ff 100644 --- a/composer.json +++ b/composer.json @@ -27,5 +27,8 @@ "OldSound\\RabbitMqBundle\\": "" } }, - "target-dir" : "OldSound/RabbitMqBundle" + "target-dir" : "OldSound/RabbitMqBundle", + "replace": { + "oldsound/rabbitmq-bundle": "self.version" + } } From 8c7ecc2afb91caced764e54f5e1e22450ea91048 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 30 May 2016 23:31:54 +0300 Subject: [PATCH 05/16] Remove changes from composer json --- composer.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ae9aa4ff..a3a44330 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev", - "dev-reconnect-fix": "1.6.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -27,8 +26,5 @@ "OldSound\\RabbitMqBundle\\": "" } }, - "target-dir" : "OldSound/RabbitMqBundle", - "replace": { - "oldsound/rabbitmq-bundle": "self.version" - } + "target-dir" : "OldSound/RabbitMqBundle" } From b3ad3f9a43da72cfbdd3d4caebd385634a5caf65 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 30 May 2016 23:44:03 +0300 Subject: [PATCH 06/16] Rollback changes to composer json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a3a44330..bcf9e8a4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.2.x-dev", + "dev-reconnect-fix": "1.6.x-dev" } }, "autoload": { From 68d9f1f329573c41a6b61838e0184bfba8ac1945 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Thu, 22 Dec 2016 17:30:15 +0200 Subject: [PATCH 07/16] Fixed dev branch name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8b3f2785..db6926fe 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "extra": { "branch-alias": { "dev-master": "1.10.x-dev", - "dev-reconnect-fix": "1.13.x-dev" + "dev-reconnect-fix-upstream": "1.13.x-dev" } }, "autoload": { From e73698bf9630288bc238916ffa59c399d828c5c8 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Thu, 22 Dec 2016 21:53:34 +0200 Subject: [PATCH 08/16] Fixed tests. Rollback changes in composer --- Tests/RabbitMq/BaseAmqpTest.php | 6 +++++- Tests/RabbitMq/ProducerTest.php | 15 +++++---------- composer.json | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Tests/RabbitMq/BaseAmqpTest.php b/Tests/RabbitMq/BaseAmqpTest.php index 21d5044b..bc6cce79 100644 --- a/Tests/RabbitMq/BaseAmqpTest.php +++ b/Tests/RabbitMq/BaseAmqpTest.php @@ -30,13 +30,17 @@ public function testNotLazyConnection() $connection = $this->getMockBuilder('PhpAmqpLib\Connection\AbstractConnection') ->disableOriginalConstructor() ->getMock(); + $channel = $this->getMockBuilder('PhpAmqpLib\Channel\AMQPChannel') + ->disableOriginalConstructor() + ->getMock(); $connection ->method('connectOnConstruct') ->willReturn(true); $connection ->expects(static::once()) - ->method('channel'); + ->method('channel') + ->willReturn($channel); new Consumer($connection, null); } diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index 08b6c1ca..44abb0f5 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -1,16 +1,7 @@ prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); $channel = $this->prophesize('\PhpAmqpLib\Channel\AMQPChannel'); - + $producer = new Producer($connection->reveal()); $channel->close()->shouldBeCalled(); $channel->confirm_select()->shouldBeCalled(); + $channel->getChannelId()->shouldBeCalled(); $channel->wait_for_pending_acks($producer->getWaitConfirmationTimeout())->shouldBeCalled(); + $connection->channel()->willReturn($channel->reveal()); + $connection->isConnected()->willReturn(false); + $producer->setChannel($channel->reveal()); $producer->enableConfirmation(); $producer->waitConfirmation(); diff --git a/composer.json b/composer.json index db6926fe..82af4225 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.10.x-dev", - "dev-reconnect-fix-upstream": "1.13.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { From 6842474cc0a8648ebb7ed62d4afec31a74551bc9 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Thu, 22 Dec 2016 22:13:26 +0200 Subject: [PATCH 09/16] Fixed tests --- Tests/RabbitMq/ProducerTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index 44abb0f5..12ffc54e 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -57,12 +57,9 @@ public function testWaitConfirmation() $channel->close()->shouldBeCalled(); $channel->confirm_select()->shouldBeCalled(); - $channel->getChannelId()->shouldBeCalled(); + $channel->getChannelId()->willReturn('channel_id'); $channel->wait_for_pending_acks($producer->getWaitConfirmationTimeout())->shouldBeCalled(); - $connection->channel()->willReturn($channel->reveal()); - $connection->isConnected()->willReturn(false); - $producer->setChannel($channel->reveal()); $producer->enableConfirmation(); $producer->waitConfirmation(); From 227e305b8d08e72d8d94fb41e913887019f79131 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Wed, 12 Apr 2017 15:46:26 +0300 Subject: [PATCH 10/16] Added one line --- Tests/RabbitMq/ProducerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index 12ffc54e..d302e411 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -73,4 +73,4 @@ public function testSetWaitConfirmationTimeout() $producer->setWaitConfirmationTimeout(5); $this->assertEquals(5, $producer->getWaitConfirmationTimeout()); } -} \ No newline at end of file +} From 9cde59cfeda66bd5636013b4d3dfe5c77d60db48 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Fri, 5 May 2017 17:17:37 +0300 Subject: [PATCH 11/16] Added minimum required php-amqplib --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d2d07242..2bd1d331 100644 --- a/composer.json +++ b/composer.json @@ -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 >=2.6.3", "psr/log": "~1.0" }, "require-dev": { From 7b94fd510cb0eb530db04ff0d8a3d6648097ae20 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Fri, 5 May 2017 17:51:02 +0300 Subject: [PATCH 12/16] Updated with accordance of php-amqplib 2.6.3 changes --- RabbitMq/BaseAmqp.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/RabbitMq/BaseAmqp.php b/RabbitMq/BaseAmqp.php index e5b853ee..626f2dd7 100644 --- a/RabbitMq/BaseAmqp.php +++ b/RabbitMq/BaseAmqp.php @@ -116,13 +116,6 @@ public function reconnect() return; } - /** - * TODO: must be done with one reconnect when php-amqplib will be updated till 2.6.3 - * see https://github.com/php-amqplib/php-amqplib/commit/2ccc97ca5b1229f9b12ea47fbab6c16fad26df41 - * see https://github.com/php-amqplib/php-amqplib/commit/c87469ecbbf38fdc18688d3216c1e253d640ba32 - */ - $this->conn->reconnect(); - $this->closeChannel(); $this->conn->reconnect(); } From 1a1b63cc05ceb16a24409039f68822cbd3b8349f Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 31 Jul 2017 13:41:55 +0300 Subject: [PATCH 13/16] Fixed composer deps. Added test cases. Removed fix. --- RabbitMq/BaseAmqp.php | 8 +------ Tests/RabbitMq/ProducerTest.php | 37 +++++++++++++++++++++++++++++---- composer.json | 2 +- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/RabbitMq/BaseAmqp.php b/RabbitMq/BaseAmqp.php index 626f2dd7..83d3ddc4 100644 --- a/RabbitMq/BaseAmqp.php +++ b/RabbitMq/BaseAmqp.php @@ -5,7 +5,6 @@ use OldSound\RabbitMqBundle\Event\AMQPEvent; use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Connection\AbstractConnection; -use PhpAmqpLib\Connection\AMQPLazyConnection; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -308,12 +307,7 @@ protected function closeChannel() if (!$this->ch) { return; } - try { - $this->ch = null; - } catch (\Exception $e) { - // ignore exception on Channel object destructor - // TODO: this workaround can be removed after php-amqplib will be updated till 2.6.3 - } + $this->ch = null; } /** diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index d302e411..280c84c1 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -3,7 +3,6 @@ namespace OldSound\RabbitMqBundle\Tests\RabbitMq; use OldSound\RabbitMqBundle\RabbitMq\Producer; -use PhpAmqpLib\Channel\AMQPChannel; class ProducerTest extends \PHPUnit_Framework_TestCase { @@ -65,12 +64,42 @@ public function testWaitConfirmation() $producer->waitConfirmation(); } - public function testSetWaitConfirmationTimeout() + /** + * @dataProvider provideTestSetWaitConfirmationTimeout + */ + public function testSetWaitConfirmationTimeout($timeout, $expectedException) { $connection = $this->prophesize('\PhpAmqpLib\Connection\AMQPLazyConnection'); $producer = new Producer($connection->reveal()); - $producer->setWaitConfirmationTimeout(5); - $this->assertEquals(5, $producer->getWaitConfirmationTimeout()); + + if ($expectedException) { + $this->expectException($expectedException); + } + + $producer->setWaitConfirmationTimeout($timeout); + $this->assertEquals($timeout, $producer->getWaitConfirmationTimeout()); + } + + public function provideTestSetWaitConfirmationTimeout() + { + return [ + 'correct timeout' => [ + 'timeout' => 5, + 'expectedException' => false, + ], + 'timeout zero' => [ + 'timeout' => 0, + 'expectedException' => false, + ], + 'timeout less then zero' => [ + 'timeout' => -1, + 'expectedException' => '\InvalidArgumentException', + ], + 'timeout not integer' => [ + 'timeout' => '5', + 'expectedException' => '\InvalidArgumentException', + ], + ]; } } diff --git a/composer.json b/composer.json index 2bd1d331..39c1f570 100644 --- a/composer.json +++ b/composer.json @@ -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 >=2.6.3", + "php-amqplib/php-amqplib": "^2.6.3", "psr/log": "~1.0" }, "require-dev": { From 6a97fde991ff517c3a9c7e8b963b6ad635473620 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 31 Jul 2017 16:04:09 +0300 Subject: [PATCH 14/16] Fixed test for unsupported PHP versions --- Tests/RabbitMq/ProducerTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index 280c84c1..d29f7240 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -73,12 +73,14 @@ public function testSetWaitConfirmationTimeout($timeout, $expectedException) $producer = new Producer($connection->reveal()); - if ($expectedException) { - $this->expectException($expectedException); + try { + $producer->setWaitConfirmationTimeout($timeout); + $this->assertEquals($timeout, $producer->getWaitConfirmationTimeout()); + } catch (\InvalidArgumentException $e) { + if ($expectedException) { + $this->addToAssertionCount(1); + } } - - $producer->setWaitConfirmationTimeout($timeout); - $this->assertEquals($timeout, $producer->getWaitConfirmationTimeout()); } public function provideTestSetWaitConfirmationTimeout() From 70243ca9d2d39358ccd16628d48dd70524628f69 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Mon, 31 Jul 2017 16:49:01 +0300 Subject: [PATCH 15/16] Fixed test for unsupported PHP versions --- Tests/RabbitMq/ProducerTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Tests/RabbitMq/ProducerTest.php b/Tests/RabbitMq/ProducerTest.php index d29f7240..abea24a4 100644 --- a/Tests/RabbitMq/ProducerTest.php +++ b/Tests/RabbitMq/ProducerTest.php @@ -85,23 +85,23 @@ public function testSetWaitConfirmationTimeout($timeout, $expectedException) public function provideTestSetWaitConfirmationTimeout() { - return [ - 'correct timeout' => [ + return array( + 'correct timeout' => array( 'timeout' => 5, 'expectedException' => false, - ], - 'timeout zero' => [ + ), + 'timeout zero' => array( 'timeout' => 0, 'expectedException' => false, - ], - 'timeout less then zero' => [ + ), + 'timeout less then zero' => array( 'timeout' => -1, 'expectedException' => '\InvalidArgumentException', - ], - 'timeout not integer' => [ + ), + 'timeout not integer' => array( 'timeout' => '5', 'expectedException' => '\InvalidArgumentException', - ], - ]; + ), + ); } } From 15af878101aa8854f143d3fabd20c76fd6ee55f2 Mon Sep 17 00:00:00 2001 From: Dmitry Balabka Date: Fri, 8 Sep 2017 13:26:28 +0300 Subject: [PATCH 16/16] Rollback reconnect fix --- RabbitMq/BaseAmqp.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/RabbitMq/BaseAmqp.php b/RabbitMq/BaseAmqp.php index 83d3ddc4..b3d62eaa 100644 --- a/RabbitMq/BaseAmqp.php +++ b/RabbitMq/BaseAmqp.php @@ -111,10 +111,13 @@ public function close() public function reconnect() { - if (!$this->conn->isConnected()) { - return; - } - + /** + * TODO: Reconnect do not restore channels. This issue persists in 2.6.3 and 2.7.0-rc1. Following PRs doesn't help: + * https://github.com/php-amqplib/php-amqplib/commit/2ccc97ca5b1229f9b12ea47fbab6c16fad26df41 + * https://github.com/php-amqplib/php-amqplib/commit/c87469ecbbf38fdc18688d3216c1e253d640ba32 + */ + $this->conn->reconnect(); + $this->closeChannel(); $this->conn->reconnect(); }