Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ajithlal's avatar

Queued events returning 404 with DB transaction

I've 3 tables for managing booking and package items. when a booking is placed three tables will be updated. So I used transaction for this. Also, I'm triggering an event to send mail. This was working fine when the listeners are not queued. But getting 404 after listeners are queued.

controller

DB::transaction(function () use ($data, $booking, $grandTotal, $SubTotalWithVat, $response) {
                $booking->amount_paid = $response->amount;
                $booking->amount_to_be_paid = $grandTotal -  $response->amount;
                $booking->total_price += $SubTotalWithVat;
                $booking->total_payable_amount += $SubTotalWithVat;
                $booking->save();

                $data['amount'] = $response->amount;
                $data['status'] = PaymentDetails::PAYMENT_STATUS_PAID;
                $paymentDetails = PaymentDetails::create($data);

                BookingAddOn::whereBookingId($booking->id)
                    ->wherePaidStatus(BookingAddOn::PAID_STATUS_UNPAID)
                    ->update(['paid_status' => BookingAddOn::PAID_STATUS_PAID]);

                BookingTable::whereBookingId($booking->id)
                    ->whereConfirmed(BookingTable::NOT_CONFIRMED)
                    ->update(['confirmed' => BookingTable::CONFIRMED]);
            });

            event(new ClientAdditionalItemsBooked($booking, $cartAddOns, $cartTables, $paymentDetails, $vat, $SubTotalWithVat, $subTotal, $grandTotal));

Added

.... implements ShouldQueue

to my listeners.

0 likes
1 reply
ajithlal's avatar
ajithlal
OP
Best Answer
Level 18

The error was with my .env file. I forgot to update the QUEUE_CONNECTION to database.

Please or to participate in this conversation.