Skip to content

Commit

Permalink
[8.x] Set chain queue when inside a batch (#35746)
Browse files Browse the repository at this point in the history
* set chain copnnection when inside a batch

* set chain connection from batch
  • Loading branch information
themsaid committed Dec 29, 2020
1 parent 2ce11ab commit d44ed21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Illuminate/Bus/Batch.php
Expand Up @@ -170,7 +170,10 @@ public function add($jobs)
$count += count($job);

return with($this->prepareBatchedChain($job), function ($chain) {
return $chain->first()->chain($chain->slice(1)->values()->all());
return $chain->first()
->allOnQueue($this->options['queue'] ?? null)
->allOnConnection($this->options['connection'] ?? null)
->chain($chain->slice(1)->values()->all());
});
} else {
$job->withBatchId($this->id);
Expand Down
1 change: 1 addition & 0 deletions tests/Bus/BusBatchTest.php
Expand Up @@ -332,6 +332,7 @@ public function test_chain_can_be_added_to_batch()

$this->assertEquals(3, $batch->totalJobs);
$this->assertEquals(3, $batch->pendingJobs);
$this->assertEquals('test-queue', $chainHeadJob->chainQueue);
$this->assertTrue(is_string($chainHeadJob->batchId));
$this->assertTrue(is_string($secondJob->batchId));
$this->assertTrue(is_string($thirdJob->batchId));
Expand Down

0 comments on commit d44ed21

Please sign in to comment.