diff --git a/app/Classes/File/Receive.php b/app/Classes/File/Receive.php index 6664000..84f64db 100644 --- a/app/Classes/File/Receive.php +++ b/app/Classes/File/Receive.php @@ -133,6 +133,10 @@ final class Receive extends Item break; } + // Queue messages if there are too many in the packet. + if ($queue = ($po->count() > config('app.queue_msgs'))) + Log::info(sprintf('%s: - Messages will be sent to the queue for processing',self::LOGKEY)); + foreach ($po as $msg) { Log::info(sprintf('%s: - Mail from [%s] to [%s]',self::LOGKEY,$msg->fftn,$msg->tftn)); @@ -140,7 +144,10 @@ final class Receive extends Item // @todo validate that the packet's zone is in the domain. // Dispatch job. - ProcessPacket::dispatch($msg); + if ($queue) + ProcessPacket::dispatch($msg); + else + ProcessPacket::dispatchSync($msg); } if ($po->errors->count()) { diff --git a/config/app.php b/config/app.php index 5eb260b..f89224d 100644 --- a/config/app.php +++ b/config/app.php @@ -18,6 +18,9 @@ return [ 'fido' => env('FIDO_DIR', 'fido'), 'packet_keep' => env('FIDO_PACKET_KEEP', FALSE), + // Number of messages in a packet that will result in them being queued for processing + 'queue_msgs' => env('FIDO_QUEUE_MSGS', 50), + /* |-------------------------------------------------------------------------- | Application Environment