Try not abort on exception when we cannot dispatch a message to be processed

This commit is contained in:
Deon George 2021-10-26 17:51:17 +11:00
parent cabf9bca8b
commit 8c127ba5da
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254

View File

@ -139,20 +139,27 @@ final class Receive extends Item
$queue = ($po->count() > config('app.queue_msgs'));
Log::info(sprintf('%s: - Messages will be sent to the queue for processing',self::LOGKEY));
$error = FALSE;
foreach ($po as $msg) {
Log::info(sprintf('%s: - Mail from [%s] to [%s]',self::LOGKEY,$msg->fftn,$msg->tftn));
// @todo Quick check that the packet should be processed by us.
// @todo validate that the packet's zone is in the domain.
// Dispatch job.
if ($queue)
MessageProcess::dispatch($msg);
else
MessageProcess::dispatchSync($msg);
try {
// Dispatch job.
if ($queue)
MessageProcess::dispatch($msg);
else
MessageProcess::dispatchSync($msg);
} catch (Exception $e) {
Log::error(sprintf('%s:! Got error dispatching message [%s] (%d:%s-%s).',self::LOGKEY,$msg->msgid,$e->getLine(),$e->getFile(),$e->getMessage()));
$error = TRUE;
}
}
if ($po->errors->count()) {
if ($po->errors->count() || $error) {
Log::info(sprintf('%s: - Not deleting packet [%s], as it has validation errors',self::LOGKEY,$this->file));
// If we want to keep the packet, we could do that logic here