diff --git a/src/Illuminate/Queue/BeanstalkdQueue.php b/src/Illuminate/Queue/BeanstalkdQueue.php index f6f6a71ee2d5..b1b24da35c64 100755 --- a/src/Illuminate/Queue/BeanstalkdQueue.php +++ b/src/Illuminate/Queue/BeanstalkdQueue.php @@ -168,9 +168,15 @@ public function bulk($jobs, $data = '', $queue = null) */ public function pop($queue = null) { - $queue = $this->getQueue($queue); + $this->pheanstalk->watch( + $tube = new TubeName($queue = $this->getQueue($queue)) + ); - $this->pheanstalk->watch(new TubeName($queue)); + foreach ($this->pheanstalk->listTubesWatched() as $watched) { + if ($watched->value !== $tube->value) { + $this->pheanstalk->ignore($watched); + } + } $job = $this->pheanstalk->reserveWithTimeout($this->blockFor); diff --git a/tests/Queue/QueueBeanstalkdQueueTest.php b/tests/Queue/QueueBeanstalkdQueueTest.php index 3ff9213a8a5d..ba34a7069305 100755 --- a/tests/Queue/QueueBeanstalkdQueueTest.php +++ b/tests/Queue/QueueBeanstalkdQueueTest.php @@ -13,6 +13,7 @@ use Pheanstalk\Contract\PheanstalkSubscriberInterface; use Pheanstalk\Pheanstalk; use Pheanstalk\Values\Job; +use Pheanstalk\Values\TubeList; use Pheanstalk\Values\TubeName; use PHPUnit\Framework\TestCase; @@ -80,9 +81,12 @@ public function testDelayedPushProperlyPushesJobOntoBeanstalkd() public function testPopProperlyPopsJobOffOfBeanstalkd() { $this->setQueue('default', 60); + $tube = new TubeName('default'); $pheanstalk = $this->queue->getPheanstalk(); - $pheanstalk->shouldReceive('watch')->once()->with(m::type(TubeName::class)); + $pheanstalk->shouldReceive('watch')->once()->with(m::type(TubeName::class)) + ->shouldReceive('listTubesWatched')->once()->andReturn(new TubeList($tube)); + $jobId = m::mock(JobIdInterface::class); $jobId->shouldReceive('getId')->once(); $job = new Job($jobId, ''); @@ -96,9 +100,12 @@ public function testPopProperlyPopsJobOffOfBeanstalkd() public function testBlockingPopProperlyPopsJobOffOfBeanstalkd() { $this->setQueue('default', 60, 60); + $tube = new TubeName('default'); $pheanstalk = $this->queue->getPheanstalk(); - $pheanstalk->shouldReceive('watch')->once()->with(m::type(TubeName::class)); + $pheanstalk->shouldReceive('watch')->once()->with(m::type(TubeName::class)) + ->shouldReceive('listTubesWatched')->once()->andReturn(new TubeList($tube)); + $jobId = m::mock(JobIdInterface::class); $jobId->shouldReceive('getId')->once(); $job = new Job($jobId, '');