{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8864","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8864/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8864/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8864/events","html_url":"https://github.com/yiisoft/yii2/pull/8864","id":90062301,"number":8864,"title":"[WIP] Queue components","user":{"login":"creocoder","id":896494,"avatar_url":"https://avatars.githubusercontent.com/u/896494?v=3","gravatar_id":"","url":"https://api.github.com/users/creocoder","html_url":"https://github.com/creocoder","followers_url":"https://api.github.com/users/creocoder/followers","following_url":"https://api.github.com/users/creocoder/following{/other_user}","gists_url":"https://api.github.com/users/creocoder/gists{/gist_id}","starred_url":"https://api.github.com/users/creocoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/creocoder/subscriptions","organizations_url":"https://api.github.com/users/creocoder/orgs","repos_url":"https://api.github.com/users/creocoder/repos","events_url":"https://api.github.com/users/creocoder/events{/privacy}","received_events_url":"https://api.github.com/users/creocoder/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:feature","name":"type:feature","color":"02d7e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-22T10:22:13Z","updated_at":"2015-06-22T13:42:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/8864","html_url":"https://github.com/yiisoft/yii2/pull/8864","diff_url":"https://github.com/yiisoft/yii2/pull/8864.diff","patch_url":"https://github.com/yiisoft/yii2/pull/8864.patch"},"body":"Usage from application side:\r\n\r\n```php\r\n// use default backend, default pool, no delay\r\nYii::$app->queue->push(SendEmailJob::className(), ['user' => $user]);\r\n// use default backend, emails pool, no delay\r\nYii::$app->queue->push(SendEmailJob::className(), ['user' => $user], 'emails'); \r\n// use default backend, emails pool, delay 15 seconds\r\nYii::$app->queue->push(SendEmailJob::className(), ['user' => $user], 'emails', 15); \r\n// use rabbitmq backend\r\nYii::$app->rabbitmq->push(SendEmailJob::className(), ['user' => $user]);\r\n```\r\n\r\nConcrette job classes:\r\n\r\n```php\r\nclass SendEmailJob extends \\yii\\queue\\Job\r\n{\r\n    /**\r\n     * @var common\\models\\User\r\n     */\r\n    protected $user;\r\n\r\n    /**\r\n     * @inheritdoc\r\n     */\r\n    public function run()\r\n    {\r\n        // ...\r\n    }\r\n}\r\n```\r\n\r\nWorkers:\r\n\r\n```sh\r\n./yii queue/listen // listen default back-end, default pool\r\n./yii queue/listen rabbitmq // listen rabbitmq back-end, default pool\r\n./yii queue/listen rabbitmq --queue=emails //listen rabbitmq back-end, emals pool\r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/114108353","html_url":"https://github.com/yiisoft/yii2/pull/8864#issuecomment-114108353","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8864","id":114108353,"user":{"login":"creocoder","id":896494,"avatar_url":"https://avatars.githubusercontent.com/u/896494?v=3","gravatar_id":"","url":"https://api.github.com/users/creocoder","html_url":"https://github.com/creocoder","followers_url":"https://api.github.com/users/creocoder/followers","following_url":"https://api.github.com/users/creocoder/following{/other_user}","gists_url":"https://api.github.com/users/creocoder/gists{/gist_id}","starred_url":"https://api.github.com/users/creocoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/creocoder/subscriptions","organizations_url":"https://api.github.com/users/creocoder/orgs","repos_url":"https://api.github.com/users/creocoder/repos","events_url":"https://api.github.com/users/creocoder/events{/privacy}","received_events_url":"https://api.github.com/users/creocoder/received_events","type":"User","site_admin":false},"created_at":"2015-06-22T13:42:50Z","updated_at":"2015-06-22T13:42:50Z","body":"@klimov-paul Because instantiating Job does not make any sence in place where you put it to queue. Note that it will be serialized and will be used in different place."}}