{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/187383777","pull_request_review_id":119153936,"id":187383777,"diff_hunk":"@@ -62,9 +63,14 @@ public function receive(callable $handler): void\n \n                 throw $e;\n             } catch (\\Throwable $e) {\n-                $this->connection->nack($AMQPEnvelope, AMQP_REQUEUE);\n+                if (!$this->connection->publishForRetry($AMQPEnvelope)) {","path":"src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php","position":18,"original_position":18,"commit_id":"4ae654b803a8d679804e677b08584558fedfce00","original_commit_id":"4ae654b803a8d679804e677b08584558fedfce00","user":{"login":"Tobion","id":610090,"avatar_url":"https://avatars3.githubusercontent.com/u/610090?v=4","gravatar_id":"","url":"https://api.github.com/users/Tobion","html_url":"https://github.com/Tobion","followers_url":"https://api.github.com/users/Tobion/followers","following_url":"https://api.github.com/users/Tobion/following{/other_user}","gists_url":"https://api.github.com/users/Tobion/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobion/subscriptions","organizations_url":"https://api.github.com/users/Tobion/orgs","repos_url":"https://api.github.com/users/Tobion/repos","events_url":"https://api.github.com/users/Tobion/events{/privacy}","received_events_url":"https://api.github.com/users/Tobion/received_events","type":"User","site_admin":false},"body":"I think you need to handle errors here as well. Otherwise it kills the whole receiver.","created_at":"2018-05-10T16:28:13Z","updated_at":"2018-05-10T16:28:13Z","html_url":"https://github.com/symfony/symfony/pull/27008#discussion_r187383777","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/27008","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/187383777"},"html":{"href":"https://github.com/symfony/symfony/pull/27008#discussion_r187383777"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/27008"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/27008","id":183291742,"html_url":"https://github.com/symfony/symfony/pull/27008","diff_url":"https://github.com/symfony/symfony/pull/27008.diff","patch_url":"https://github.com/symfony/symfony/pull/27008.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/27008","number":27008,"state":"open","locked":false,"title":"[Messenger][AmqpExt] Add a retry mechanism for AMQP messages","user":{"login":"sroze","id":804625,"avatar_url":"https://avatars0.githubusercontent.com/u/804625?v=4","gravatar_id":"","url":"https://api.github.com/users/sroze","html_url":"https://github.com/sroze","followers_url":"https://api.github.com/users/sroze/followers","following_url":"https://api.github.com/users/sroze/following{/other_user}","gists_url":"https://api.github.com/users/sroze/gists{/gist_id}","starred_url":"https://api.github.com/users/sroze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sroze/subscriptions","organizations_url":"https://api.github.com/users/sroze/orgs","repos_url":"https://api.github.com/users/sroze/repos","events_url":"https://api.github.com/users/sroze/events{/privacy}","received_events_url":"https://api.github.com/users/sroze/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | master\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | ø\r\n| License       | MIT\r\n| Doc PR        | symfony/symfony-docs#9756\r\n\r\nOne of the most asked features (and required to have an enterprise-grade management of errors). I chose the approach of an AmqpExt-only retry mechanism to ensure we have a great user experience with this one at least. There are discussions on-going (#26945) to have more generic things like that across adapters. \r\n\r\n---\r\n\r\n# So what's the point? \r\n\r\nWhen processing some messages, some error might happen. It might be that one of our 3rd party is down, that something is wrong with the last deployment, etc... All of these things will throw exceptions in the message handlers. The way of tackling this problem is very well described in @odolbeau's [Swarrot Retry provider real-life example](https://github.com/swarrot/swarrot/tree/master/src/Swarrot/Processor/Retry#real-example).\r\n\r\n# How to configure it\r\n\r\nSame than for the rest, this can be configured both via the DSN or the `options` when creating the adapter. Here is a bunch of working DSNs with their corresponding effect:\r\n\r\n1. **Enable 3 retries** before having an exception\r\n```yaml\r\namqp://guest:guest@localhost:5672/%2f/messages\r\n    ?retry[attempts]=3\r\n```\r\n\r\n2. **Enable 3 retries** before message to be queue in a \"dead queue\" (i.e. messages to be looked at manually later)\r\n```yaml\r\namqp://guest:guest@localhost:5672/%2f/messages\r\n    ?retry[attempts]=3\r\n    &retry[dead_queue]=dead_queue\r\n```\r\n\r\n3. **Enable 3 retries, dead queue and custom settings**\r\n```yaml\r\namqp://guest:guest@localhost:5672/%2f/messages\r\n    ?retry[attempts]=3\r\n    &retry[exchange_name]=retry\r\n    &retry[routing_key_pattern]=retry_attempt_%25attempt%25\r\n    &retry[queue_name_pattern]=retry_queue_%attempt%\r\n    &retry[dead_queue]=dead_queue\r\n    &retry[dead_routing_key]=dead_routing_key\r\n```\r\n\r\n4. **Enable 3 retries, with custom TTLs per attempt.** Waits 10 seconds before retrying for the first attempt, 30 seconds for the 2nd attempt and 5 minutes for the 3rd one.\r\n```yaml\r\namqp://guest:guest@localhost:5672/%2f/messages\r\n    ?retry[attempts]=3\r\n    &retry[ttls][0]=10000\r\n    &retry[ttls][1]=30000\r\n    &retry[ttls][2]=300000\r\n```\r\n","created_at":"2018-04-22T20:12:05Z","updated_at":"2018-05-10T16:28:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"30295c525a7ef134716adc3542a535bc70a8dad5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":100378,"url":"https://api.github.com/repos/symfony/symfony/labels/Feature","name":"Feature","color":"02e10c","default":false},{"id":877085690,"url":"https://api.github.com/repos/symfony/symfony/labels/Messenger","name":"Messenger","color":"dddddd","default":false},{"id":237550465,"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Reviewed","name":"Status: Reviewed","color":"bfe5bf","default":false}],"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/17","html_url":"https://github.com/symfony/symfony/milestone/17","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/17/labels","id":2795131,"number":17,"title":"4.1","description":"https://symfony.com/roadmap?version=4.1#checker","creator":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":414,"state":"open","created_at":"2017-09-26T15:40:00Z","updated_at":"2018-05-10T15:07:56Z","due_on":"2018-05-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/27008/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/27008/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/27008/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/4ae654b803a8d679804e677b08584558fedfce00","head":{"label":"sroze:retry-amqp-messages","ref":"retry-amqp-messages","sha":"4ae654b803a8d679804e677b08584558fedfce00","user":{"login":"sroze","id":804625,"avatar_url":"https://avatars0.githubusercontent.com/u/804625?v=4","gravatar_id":"","url":"https://api.github.com/users/sroze","html_url":"https://github.com/sroze","followers_url":"https://api.github.com/users/sroze/followers","following_url":"https://api.github.com/users/sroze/following{/other_user}","gists_url":"https://api.github.com/users/sroze/gists{/gist_id}","starred_url":"https://api.github.com/users/sroze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sroze/subscriptions","organizations_url":"https://api.github.com/users/sroze/orgs","repos_url":"https://api.github.com/users/sroze/repos","events_url":"https://api.github.com/users/sroze/events{/privacy}","received_events_url":"https://api.github.com/users/sroze/received_events","type":"User","site_admin":false},"repo":{"id":15307551,"name":"symfony","full_name":"sroze/symfony","owner":{"login":"sroze","id":804625,"avatar_url":"https://avatars0.githubusercontent.com/u/804625?v=4","gravatar_id":"","url":"https://api.github.com/users/sroze","html_url":"https://github.com/sroze","followers_url":"https://api.github.com/users/sroze/followers","following_url":"https://api.github.com/users/sroze/following{/other_user}","gists_url":"https://api.github.com/users/sroze/gists{/gist_id}","starred_url":"https://api.github.com/users/sroze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sroze/subscriptions","organizations_url":"https://api.github.com/users/sroze/orgs","repos_url":"https://api.github.com/users/sroze/repos","events_url":"https://api.github.com/users/sroze/events{/privacy}","received_events_url":"https://api.github.com/users/sroze/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sroze/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/sroze/symfony","forks_url":"https://api.github.com/repos/sroze/symfony/forks","keys_url":"https://api.github.com/repos/sroze/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sroze/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sroze/symfony/teams","hooks_url":"https://api.github.com/repos/sroze/symfony/hooks","issue_events_url":"https://api.github.com/repos/sroze/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/sroze/symfony/events","assignees_url":"https://api.github.com/repos/sroze/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/sroze/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/sroze/symfony/tags","blobs_url":"https://api.github.com/repos/sroze/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sroze/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sroze/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/sroze/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sroze/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/sroze/symfony/languages","stargazers_url":"https://api.github.com/repos/sroze/symfony/stargazers","contributors_url":"https://api.github.com/repos/sroze/symfony/contributors","subscribers_url":"https://api.github.com/repos/sroze/symfony/subscribers","subscription_url":"https://api.github.com/repos/sroze/symfony/subscription","commits_url":"https://api.github.com/repos/sroze/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/sroze/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/sroze/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/sroze/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/sroze/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/sroze/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sroze/symfony/merges","archive_url":"https://api.github.com/repos/sroze/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sroze/symfony/downloads","issues_url":"https://api.github.com/repos/sroze/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/sroze/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/sroze/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/sroze/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sroze/symfony/labels{/name}","releases_url":"https://api.github.com/repos/sroze/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/sroze/symfony/deployments","created_at":"2013-12-19T09:28:20Z","updated_at":"2018-05-07T14:36:21Z","pushed_at":"2018-05-10T15:13:42Z","git_url":"git://github.com/sroze/symfony.git","ssh_url":"git@github.com:sroze/symfony.git","clone_url":"https://github.com/sroze/symfony.git","svn_url":"https://github.com/sroze/symfony","homepage":"symfony.com","size":112212,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:4.1","ref":"4.1","sha":"3cc4a701e6f24cb2eaaf1234b331f182dea0c9b4","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2018-05-10T13:38:22Z","pushed_at":"2018-05-10T15:42:43Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"https://symfony.com","size":116940,"stargazers_count":17505,"watchers_count":17505,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":6198,"mirror_url":null,"archived":false,"open_issues_count":825,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":6198,"open_issues":825,"watchers":17505,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/27008"},"html":{"href":"https://github.com/symfony/symfony/pull/27008"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/27008"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/27008/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/27008/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/27008/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/4ae654b803a8d679804e677b08584558fedfce00"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Tobion"}}