Hey guys,
I have a SendEmail command that is dispatched like so:
Bus::dispatch(
new SendEmail(
'user@email.com',
"Test Subject",
"emails.template",
$emailData)
);
I'd like to make it so it ALWAYS just puts this job into the queue so that if I'm not running php artisan queue:listen
then the SendEmail command will just sit in the job table not being sent.
I understood this was the default behavior but it seems that if the queue is not running it simply runs the SendEmail command in the current request, thus adding a wait time for the user at this point.
It's entirely possible I've not created the Command correctly so I've included it below just in case. Any pointers would be useful thanks!
class SendEmail extends Command implements SelfHandling, ShouldBeQueued {
use InteractsWithQueue, SerializesModels;
...
public function handle()
{
Mail::send($this->template, $this->parameters, function ($message)
{
$message->to($this->email, 'User')->subject($this->subject);
});
}
...
Doh. I knew it'd be something simple, I was using the "sync" queue driver! As soon as I changed it over to "database" it worked as expected.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community