public function boot() { $this->package('orlissenberg/laravel-zendserver-pushqueue'); // 1. Need a route to marshal requests. \Route::any("/queue/zendserver", function () { /** @var ZendJobQueue $connection */ $connection = \Queue::connection("zendjobqueue"); $connection->marshal(); }); // 2. Add the connector to the Queue facade. \Queue::addConnector("zendserver", function () { return app()->make("\\Orlissenberg\\Queue\\Connectors\\ZendJobQueueConnector"); }); // 3. Add configuration to the app/config/queue.php /* 'zendjob' => [ 'driver' => 'zendserver', 'options' => [], 'callback-url' => '/queue/zendserver', ], */ // 4. Enable the test route (optional for testing only) /* \Route::get( "/queue/zendtest", function () { $connection = \Queue::connection("zendjobqueue"); $connection->push("\\Orlissenberg\\Queue\\Handlers\\TestHandler@handle", ["laravel4" => "rocks"]); return "Job queued."; } ); */ }
/** * Execute the console command. * * @return mixed * @throws Exception */ public function handle() { $user = User::findOrFail($this->argument('userId')); if ($this->option('regenerate')) { $albums = $user->albums; } else { $albums = $user->albums()->whereNull('thumbnailImageFileId')->get(); } foreach ($albums as $album) { \Queue::connection('sync')->push(new MakeAlbumThumbnailJob($album)); } }
/** * Execute the console command. * * @return mixed * @throws Exception */ public function handle() { $image = Image::findOrFail($this->argument('imageId')); if (!empty($image->thumbnailImageFileId)) { if (!$this->option('regenerate')) { throw new Exception("Image already has a thumbnail and --regenerate was not set"); } $thumbnail = $image->getThumbnailImageFile(); \Queue::connection('sync')->push(new DeleteFileJob($thumbnail->getPath())); $thumbnail->delete(false); } \Queue::connection('sync')->push(new MakeThumbnailJob($image->getImageFile())); }
public function getDriver($alias) { try { if ($alias == "Auth") { $driver = \Auth::driver(); } elseif ($alias == "DB") { $driver = \DB::connection(); } elseif ($alias == "Cache") { $driver = \Cache::driver(); } elseif ($alias == "Queue") { $driver = \Queue::connection(); } else { return false; } return get_class($driver); } catch (\Exception $e) { $this->error("Could not determine driver/connection for {$alias}."); return false; } }
/** * Execute the console command. * * @return mixed * @throws Exception */ public function handle() { $album = Album::findOrFail($this->argument('albumId')); \Queue::connection('sync')->push(new MakeAlbumThumbnailJob($album)); }