laravel-actions
laravel-actions copied to clipboard
Dispatch job with named queue
Hi, I've been searching the docs to find a way to dispatch actions as jobs in specific queues, but I haven't found it yet. I'm pretty sure I'm missing something. Does anyone know how to achieve it with this (wonderful) package? For example:
config.php:
// ... (this is a custom config.php entry, it doesn't exist in fresh Laravel installations)
'default_queue_names' => [
'erp' => [
'data_receive' => 'erp_data_receive',
'data_send' => 'erp_data_send'
]
]
CreateCustomer.php
...
use AsAction;
public function handle(array $data): Customer
{
try {
$customer = Customer::create($data);
} catch (\Throwable $th) {
throw_error($th);
}
// here I would want to do something like <---
SendCustomerToErp::onQueue(
config('queue.default_queue_names.erp.data_send')
)->dispatch($customer);
}
Hi @rfaugusto.
Fist of all, use AsJob method. Check docs https://laravelactions.com/2.x/as-job.html;
Next step is configure the Job dispatch https://laravelactions.com/2.x/as-job.html#configurejob
Awesome! Thank you very much.