Skip to content
macropay-solutions edited this page Sep 8, 2025 · 19 revisions

See also Maravel Template Wiki and Maravelith Template Wiki

Notes:

  • From version 10.51.7

SQS FIFO and Fair Queues

Maravel framework supports Amazon SQS FIFO (First-In-First-Out) queues through message deduplication.

Maravel example:

\dispatch(new JobExample($payload))->onGroup('customer-' . $payload['customer_id']);

Maravelith example:

JobExample::dispatch($payload)->onGroup('customer-' . $payload['customer_id']);

Implement a deduplicationId method with string return type in your job to prevent for 5 minutes duplicate dispatches (if not, a default Str::orderedUuid()->toString() will be used meaning duplicates will be processed):

    /**
     * Get the job's deduplication ID.
     */
    public function deduplicationId(): string
    {
        return 'prefix-' . $this->customId;
    }
  • From version 10.49.3, to prevent the parent script that runs the queue command from exiting with error due to memory exhausted, you should call it like:

    php artisan queue:work || echo "error..."

    php artisan queue:listen || echo "error..."

  • \Illuminate\Support\Facades\Queue::push should not be used in combination with ShouldBeUnique!

  • Eloquent accessors for columns used in relations are called with param null when a relation is instantiated so, they must be defined with ?string param and return type even if the column is not nullable in DB.

    public function getColAttribute(?string $value): ?string
    {
        return \is_string($value) ? \strtolower($value) : null;
    }
  • Avoid piling up email addresses when sending emails in a loop via queue with the same mailable:
$maillable = (new ChildMailable())->onQueue('emails');

foreach ([...] as $email) {
    Mail::to($email)->queue($maillable);
    $message->to = []; // without this the emails will pile up in the $maillable object
}

// or

foreach ([...] as $email) {
    Mail::to($email)->queue((new ChildMailable())->onQueue('emails'));
}