2

I am trying to update a database row within a queued job which works when my queue connection is set to sync but now when it's set to database.

Edit: Fixed Serialization issue, update db in queue issue still persists.

public function handle()
    {

      $id = $this->settings->id;
      $server = $this->settings->server;
      $number = $this->settings->number;
      $api_script = storage_path('script.py');
      $delay = 5;

      //Determine Delay

      //Process Script Here

      //Check If Script Successful

      DB::table('orders')->where('order_id', $this->settings->order_id)->update(['status' => "Finalising..."]);

      ProcessEmails::dispatch($this->settings)->delay(now()->addMinutes($delay));
      // echo $process->getOutput();
    }

Above is the job that I want to execute, the update database command works in sync but not when the connection is set to database.

Thanks for your help!

8
  • This problem shows up in the same environment only by changing queue driver or is the same application one local and one in production? Commented Aug 25, 2019 at 0:32
  • @dparoli Same environment, only changing the .env variable. Commented Aug 25, 2019 at 0:34
  • Take a look here, seems your same problem even if not linked to queues: stackoverflow.com/questions/45266254/… and here: laravel.com/docs/5.8/deployment#optimizing-route-loading where it write about serialization. Commented Aug 25, 2019 at 0:38
  • @dparoli Thanks for that,I actually already sorted the route issue by moving the return view to a controller. The queue/database update issue still persists. Commented Aug 25, 2019 at 0:43
  • Glad to be of help. Please try to use \DB::table('orders')... Commented Aug 25, 2019 at 0:51

1 Answer 1

5

Overtime you encounter some really, really stupid mistakes. My issue was resolved by simply restarting the queue:work command. I had the queue:work running throughout all my edit and by ending it and starting it back up.. boom, magically my DB inserts work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.