Reputation: 1028
So I have a laravel project running in production, and using supervisor to handle jobs and notifications.
The problem is, after supervisor runs for a couple hours, it starts to send duplicate notifications, and it seems that the longer it runs, the more times a notification will be sent out (It's happened where the same notification gets sent out 4 times).
My notification looks like the following:
class MessageNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct($opts = [])
{
$this->connection = 'database';
$this->queue = 'sendMail';
}
public function via($notifiable)
{
return ['mail', 'database', 'broadcast'];
}
public function toMail($notifiable)
{
$mesg = (new MailMessage)
// ... defining message stuff
return $mesg;
}
public function toArray($notifiable)
{
return [
// .. defining array stuff
];
}
public function toBroadcast($notifiable){
return (new BroadcastMessage($this->toArray($notifiable)));
}
}
and my queue config looks like the following:
return [
'default' => env('QUEUE_CONNECTION', 'sync'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'sendMail',
'retry_after' => 90,
],
],
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
And my supervisor config is the following:
[program:laravel-worker]
command=php /app/artisan queue:work database --queue=sendMail --sleep=3 --tries=3 --timeout=75
process_name=%(program_name)s_%(process_num)02d
numprocs=8
priority=999
autostart=true
autorestart=true
startsecs=1
startretries=3
user=yastechco
redirect_stderr=true
stdout_logfile=/app/worker.log
This doesn't happen running in development on my local machine.
If it matters, the production server is running on CentOS 7.6.1810 and Supervisord 3.1.4
Upvotes: 0
Views: 988
Reputation: 1028
I ended up configuring redis as my queue adapter, and it appears to have fixed the problem
Upvotes: 2