diff --git a/app/Jobs/ProcessANPCAllData.php b/app/Jobs/ProcessANPCAllData.php index 3e0f93c..c9001db 100644 --- a/app/Jobs/ProcessANPCAllData.php +++ b/app/Jobs/ProcessANPCAllData.php @@ -50,8 +50,8 @@ public function handle() $this->handleIncidents($incidents); - dispatch(new CheckIsActive($incidents)); - dispatch(new CheckImportantFireIncident()); + dispatch((new CheckIsActive($incidents))->onQueue('high')); + dispatch((new CheckImportantFireIncident())->onQueue('low')); } private function handleIncidents($data) diff --git a/app/Jobs/ProcessICNFPDFData.php b/app/Jobs/ProcessICNFPDFData.php index 41b8cf0..1060e3c 100644 --- a/app/Jobs/ProcessICNFPDFData.php +++ b/app/Jobs/ProcessICNFPDFData.php @@ -87,7 +87,7 @@ public function handle() $fileId = $match[1]; $url = env('ICNF_PDF_URL').$fileId; - dispatch(new ProcessICNFPDF($this->incident[0], $url)); + dispatch((new ProcessICNFPDF($this->incident[0], $url))->onQueue('low')); } } } diff --git a/app/Jobs/UpdateICNFData.php b/app/Jobs/UpdateICNFData.php index 934caf7..e4c5940 100644 --- a/app/Jobs/UpdateICNFData.php +++ b/app/Jobs/UpdateICNFData.php @@ -82,7 +82,7 @@ public function handle() ->get(); foreach ($incidents as $incident) { - dispatch(new ProcessICNFFireData($incident)); + dispatch((new ProcessICNFFireData($incident))->onQueue('low')); } } } diff --git a/app/Observers/IncidentObserver.php b/app/Observers/IncidentObserver.php index 527d45c..7675047 100644 --- a/app/Observers/IncidentObserver.php +++ b/app/Observers/IncidentObserver.php @@ -16,18 +16,19 @@ protected static function boot() static::created(function ($incident) { //Log::info("Incident Created Event Fire observer: ".$incident); - dispatch(new SaveIncidentHistory($incident)); - dispatch(new SaveIncidentStatusHistory($incident)); + dispatch((new SaveIncidentHistory($incident))->onQueue('low')); + dispatch((new SaveIncidentStatusHistory($incident))->onQueue('low')); + dispatch((new SaveIncidentStatusHistory($incident))->onQueue('low')); if ($incident->isFire) { - dispatch(new HandleNewIncidentSocialMedia($incident)); - dispatch(new ProcessICNFFireData($incident)); + dispatch((new HandleNewIncidentSocialMedia($incident))->onQueue('high')); + dispatch((new ProcessICNFFireData($incident))->onQueue('low')); } }); static::updated(function ($incident) { //Log::info("Incident updated Event Fire observer: ".$incident); - dispatch(new SaveIncidentStatusHistory($incident)); - dispatch(new SaveIncidentHistory($incident)); + dispatch((new SaveIncidentStatusHistory($incident))->onQueue('low')); + dispatch((new SaveIncidentHistory($incident))->onQueue('low')); }); static::deleted(function ($incident) { diff --git a/config/queue.php b/config/queue.php new file mode 100644 index 0000000..b378124 --- /dev/null +++ b/config/queue.php @@ -0,0 +1,59 @@ + env('QUEUE_CONNECTION', 'sync'), + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | + */ + + 'connections' => [ + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, + 'block_for' => null, + 'after_commit' => false, + ], + 'redis_high' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'high', + 'retry_after' => 90, + 'block_for' => null, + 'after_commit' => false, + ], + 'redis_low' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'low', + 'retry_after' => 90, + 'block_for' => null, + 'after_commit' => false, + ], + ], + + +]; diff --git a/docker-compose.yml b/docker-compose.yml index f2c546e..e77f6fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,7 +87,7 @@ services: - fogos.mongodb networks: - fogos - command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600 + command: php artisan queue:work --queue=high,default,low --sleep=3 --tries=3 --max-time=3600 volumes: mongodb_data: