/** * Store the job in the database. * * Returns the id of the job. * * @param string $job * @param mixed $data * @param int $delay * * @return int */ public function storeJob($job, $data, $delay = 0) { $payload = $this->createPayload($job, $data); $database = Config::get('database'); if ($database['default'] === 'odbc') { $row = DB::select(DB::raw("SELECT laq_async_queue_seq.NEXTVAL FROM DUAL")); $id = $row[0]->nextval; $job = new Job(); $job->id = $id; $job->status = Job::STATUS_OPEN; $job->delay = $delay; $job->payload = $payload; $job->save(); } else { if ($database['default'] === 'mysql') { $payload = $this->createPayload($job, $data); $job = new Job(); $job->status = Job::STATUS_OPEN; $job->delay = $delay; $job->payload = $payload; $job->save(); $id = $job->id; } } return $id; }
/** * Store the job in the database. * * Returns the id of the job. * * @param string $job * @param mixed $data * @param int $delay * * @return int */ public function storeJob($job, $data, $delay = 0) { $payload = $this->createPayload($job, $data); $job = new Job(); $job->status = Job::STATUS_OPEN; $job->delay = $delay; $job->payload = $payload; $job->save(); return $job->id; }
/** * Execute the console command. * * @return void */ public function fire() { $item = Job::findOrFail($this->argument('job_id')); if ($delay = (int) $this->option('delay')) { sleep($delay); } $job = new AsyncJob($this->laravel, $item); $job->fire(); }
/** * Delete the job from the queue. * * @return void */ public function delete() { parent::delete(); $this->job->delete(); }