Tutorials
How can I distribute search jobs across multiple queues?
You can use the setQueueResolver() method to distribute search jobs across multiple queues:
For example, let's say you have 10 search queues you want to utilise, you could distribute search jobs between them randomly:
\Aero\Search\Jobs\SearchJob::setQueueResolver(function () {
return 'search-' . rand(1, 10);
});
Or equally:
protected static $queueIndex = 0;
public function boot()
{
\Aero\Search\Jobs\SearchJob::setQueueResolver(function () {
return 'search-' . (self::$queueIndex++ % 10 + 1);
});
}
The examples will dispatch the search jobs on queues from search-1 to search-10.