Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Queue Prefixing
/**
* Get the queue or return the default.
*
* @param string|null $queue
* @return string
*/
public function getQueue($queue)
{
$queue = $queue ?: $this->default;
return $this->getPrefix() . $queue;
}
/**
* Get the queue prefix.
*
* @return string
*/
public function getPrefix()
{
return config('queue.prefix');
}
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Prefix
|--------------------------------------------------------------------------
|
| In order to prevent crosstalk between applications on the same server
| you may add a 'prefix' to your queues. You will still interact
| with your queues the same way, and the prefix will be applied
| automatically where appropraite.
|
*/
'prefix' => env('QUEUE_PREFIX', ''),
/**
* Get the queue name for the worker.
*
* @param string $connection
* @return string
*/
protected function getQueue($connection)
{
$queue = $this->option('queue') ?: $this->laravel['config']->get(
"queue.connections.{$connection}.queue", 'default'
);
return $this->laravel['config']->get("queue.prefix") . $queue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment