Only queue messages if the packet has too many

This commit is contained in:
Deon George 2021-08-25 22:32:15 +10:00
parent 314ec304a7
commit b614779290
2 changed files with 11 additions and 1 deletions

View File

@ -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()) {

View File

@ -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