{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments/193733684","pull_request_review_id":126762858,"id":193733684,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzczMzY4NA==","diff_hunk":"@@ -86,6 +86,65 @@ that will do the required processing for your message::\n        }\n     }\n \n+Envelope\n+--------\n+\n+The notion of an envelope is a concept that helps add context around the\n+messages. An envelope is a message and a set of data. From a user's perspective, this\n+allows you to set some configuration around the message. For example, to set the serialization\n+groups used when the message goes through the transport layer, wrap your message\n+in an ``Envelope`` and add some ``SerializerConfiguration``::\n+\n+    use Symfony\\Component\\Messenger\\Envelope;\n+    use Symfony\\Component\\Messenger\\Transport\\Serialization\\SerializerConfiguration;\n+\n+    $bus->dispatch(\n+        (new Envelope($message))->with(new SerializerConfiguration([\n+            'groups' => ['my_serialization_groups'],\n+        ]))\n+    );\n+\n+At the moment, the Symfony Messenger has the following built-in envelopes:\n+\n+1. :class:`Symfony\\\\Component\\\\Messenger\\\\Transport\\\\Serialization\\\\SerializerConfiguration`,\n+   to configure the serialization groups used by the transport.\n+2. :class:`Symfony\\\\Component\\\\Messenger\\\\Middleware\\\\Configuration\\\\ValidationConfiguration`,\n+   to configure the validation groups used when the validation middleware is enabled.\n+3. :class:`Symfony\\\\Component\\\\Messenger\\\\Asynchronous\\\\Transport\\\\ReceivedMessage`,\n+   an internal item that marks the message as received from a transport.\n+\n+Instead of dealing directly with the messages in the middleware you can receive the\n+envelope by implementing the :class:`Symfony\\\\Component\\\\Messenger\\\\EnvelopeAwareInterface`\n+marker, like this::\n+\n+    use Symfony\\Component\\Messenger\\Asynchronous\\Transport\\ReceivedMessage;\n+    use Symfony\\Component\\Messenger\\Middleware\\MiddlewareInterface;\n+    use Symfony\\Component\\Messenger\\EnvelopeAwareInterface;\n+\n+    class MyOwnMiddleware implements MiddlewareInterface, EnvelopeAwareInterface\n+    {\n+        public function handle($message, callable $next)\n+        {\n+            // $message here is an `Envelope` object, because this middleware\n+            // implements the EnvelopeAwareInterface interface. Otherwise,\n+            // it would be the \"original\" message.\n+\n+            if (null !== $message->get(ReceivedMessage::class)) {","path":"components/messenger.rst","position":47,"original_position":47,"commit_id":"c9a625e3d2affb1c26f79de8e20fee91a1b13702","original_commit_id":"c9a625e3d2affb1c26f79de8e20fee91a1b13702","user":{"login":"weaverryan","id":121003,"node_id":"MDQ6VXNlcjEyMTAwMw==","avatar_url":"https://avatars1.githubusercontent.com/u/121003?v=4","gravatar_id":"","url":"https://api.github.com/users/weaverryan","html_url":"https://github.com/weaverryan","followers_url":"https://api.github.com/users/weaverryan/followers","following_url":"https://api.github.com/users/weaverryan/following{/other_user}","gists_url":"https://api.github.com/users/weaverryan/gists{/gist_id}","starred_url":"https://api.github.com/users/weaverryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaverryan/subscriptions","organizations_url":"https://api.github.com/users/weaverryan/orgs","repos_url":"https://api.github.com/users/weaverryan/repos","events_url":"https://api.github.com/users/weaverryan/events{/privacy}","received_events_url":"https://api.github.com/users/weaverryan/received_events","type":"User","site_admin":false},"body":"Is this `get()` method something that lives on `Envelope`? Isn't there always just one message inside an Envelope? If so, why do we pass an argument here? Or, could you also pass something like `$message->get(SerializerConfiguration::class)` to get those types of things out?\r\n\r\nAlso, suppose some similar code: if `$message->get(MyMessage::class)` is null, does it mean that this message is NOT originally a `MyMessage` isntance, right? I mean, it's equivalent to `!$message instanceof MyMessage` in a middleware without `EnvelopAwareInterface`?\r\n\r\nSome inline comments with some of these answers might be all we need :)","created_at":"2018-06-07T12:50:12Z","updated_at":"2018-06-07T12:53:39Z","html_url":"https://github.com/symfony/symfony-docs/pull/9757#discussion_r193733684","pull_request_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments/193733684"},"html":{"href":"https://github.com/symfony/symfony-docs/pull/9757#discussion_r193733684"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757","id":187218994,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg3MjE4OTk0","html_url":"https://github.com/symfony/symfony-docs/pull/9757","diff_url":"https://github.com/symfony/symfony-docs/pull/9757.diff","patch_url":"https://github.com/symfony/symfony-docs/pull/9757.patch","issue_url":"https://api.github.com/repos/symfony/symfony-docs/issues/9757","number":9757,"state":"open","locked":false,"title":"[Messenger] Add the Envelope in the documentation","user":{"login":"sroze","id":804625,"node_id":"MDQ6VXNlcjgwNDYyNQ==","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":"Because we've merged this beautiful PR :)","created_at":"2018-05-10T15:05:24Z","updated_at":"2018-06-07T12:53:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"979f2882536233446eae2371f299cd5e3f817bc8","assignee":{"login":"javiereguiluz","id":73419,"node_id":"MDQ6VXNlcjczNDE5","avatar_url":"https://avatars3.githubusercontent.com/u/73419?v=4","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"assignees":[{"login":"javiereguiluz","id":73419,"node_id":"MDQ6VXNlcjczNDE5","avatar_url":"https://avatars3.githubusercontent.com/u/73419?v=4","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":903620843,"node_id":"MDU6TGFiZWw5MDM2MjA4NDM=","url":"https://api.github.com/repos/symfony/symfony-docs/labels/Messenger","name":"Messenger","color":"dddddd","default":false},{"id":390692613,"node_id":"MDU6TGFiZWwzOTA2OTI2MTM=","url":"https://api.github.com/repos/symfony/symfony-docs/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"1d76db","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony-docs/issues/9757/comments","statuses_url":"https://api.github.com/repos/symfony/symfony-docs/statuses/c9a625e3d2affb1c26f79de8e20fee91a1b13702","head":{"label":"sroze:messenger-envelope","ref":"messenger-envelope","sha":"c9a625e3d2affb1c26f79de8e20fee91a1b13702","user":{"login":"sroze","id":804625,"node_id":"MDQ6VXNlcjgwNDYyNQ==","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":15308361,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMwODM2MQ==","name":"symfony-docs","full_name":"sroze/symfony-docs","owner":{"login":"sroze","id":804625,"node_id":"MDQ6VXNlcjgwNDYyNQ==","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-docs","description":"The Symfony2 documentation","fork":true,"url":"https://api.github.com/repos/sroze/symfony-docs","forks_url":"https://api.github.com/repos/sroze/symfony-docs/forks","keys_url":"https://api.github.com/repos/sroze/symfony-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sroze/symfony-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sroze/symfony-docs/teams","hooks_url":"https://api.github.com/repos/sroze/symfony-docs/hooks","issue_events_url":"https://api.github.com/repos/sroze/symfony-docs/issues/events{/number}","events_url":"https://api.github.com/repos/sroze/symfony-docs/events","assignees_url":"https://api.github.com/repos/sroze/symfony-docs/assignees{/user}","branches_url":"https://api.github.com/repos/sroze/symfony-docs/branches{/branch}","tags_url":"https://api.github.com/repos/sroze/symfony-docs/tags","blobs_url":"https://api.github.com/repos/sroze/symfony-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sroze/symfony-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sroze/symfony-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sroze/symfony-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sroze/symfony-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/sroze/symfony-docs/languages","stargazers_url":"https://api.github.com/repos/sroze/symfony-docs/stargazers","contributors_url":"https://api.github.com/repos/sroze/symfony-docs/contributors","subscribers_url":"https://api.github.com/repos/sroze/symfony-docs/subscribers","subscription_url":"https://api.github.com/repos/sroze/symfony-docs/subscription","commits_url":"https://api.github.com/repos/sroze/symfony-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sroze/symfony-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sroze/symfony-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sroze/symfony-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sroze/symfony-docs/contents/{+path}","compare_url":"https://api.github.com/repos/sroze/symfony-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sroze/symfony-docs/merges","archive_url":"https://api.github.com/repos/sroze/symfony-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sroze/symfony-docs/downloads","issues_url":"https://api.github.com/repos/sroze/symfony-docs/issues{/number}","pulls_url":"https://api.github.com/repos/sroze/symfony-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/sroze/symfony-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/sroze/symfony-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sroze/symfony-docs/labels{/name}","releases_url":"https://api.github.com/repos/sroze/symfony-docs/releases{/id}","deployments_url":"https://api.github.com/repos/sroze/symfony-docs/deployments","created_at":"2013-12-19T10:03:02Z","updated_at":"2018-01-08T14:42:21Z","pushed_at":"2018-06-04T08:27:12Z","git_url":"git://github.com/sroze/symfony-docs.git","ssh_url":"git@github.com:sroze/symfony-docs.git","clone_url":"https://github.com/sroze/symfony-docs.git","svn_url":"https://github.com/sroze/symfony-docs","homepage":"http://symfony.com/doc/current/","size":45588,"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":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"12e79696e6b59119f47c246331a47f4b11a26c5d","user":{"login":"symfony","id":143937,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MzkzNw==","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":521583,"node_id":"MDEwOlJlcG9zaXRvcnk1MjE1ODM=","name":"symfony-docs","full_name":"symfony/symfony-docs","owner":{"login":"symfony","id":143937,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MzkzNw==","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-docs","description":"The Symfony documentation","fork":false,"url":"https://api.github.com/repos/symfony/symfony-docs","forks_url":"https://api.github.com/repos/symfony/symfony-docs/forks","keys_url":"https://api.github.com/repos/symfony/symfony-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony-docs/teams","hooks_url":"https://api.github.com/repos/symfony/symfony-docs/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony-docs/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony-docs/events","assignees_url":"https://api.github.com/repos/symfony/symfony-docs/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony-docs/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony-docs/tags","blobs_url":"https://api.github.com/repos/symfony/symfony-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony-docs/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony-docs/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony-docs/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony-docs/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony-docs/subscription","commits_url":"https://api.github.com/repos/symfony/symfony-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony-docs/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony-docs/merges","archive_url":"https://api.github.com/repos/symfony/symfony-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony-docs/downloads","issues_url":"https://api.github.com/repos/symfony/symfony-docs/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony-docs/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony-docs/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony-docs/deployments","created_at":"2010-02-17T08:43:51Z","updated_at":"2018-06-07T07:54:53Z","pushed_at":"2018-06-07T08:33:11Z","git_url":"git://github.com/symfony/symfony-docs.git","ssh_url":"git@github.com:symfony/symfony-docs.git","clone_url":"https://github.com/symfony/symfony-docs.git","svn_url":"https://github.com/symfony/symfony-docs","homepage":"https://symfony.com/doc","size":47027,"stargazers_count":1437,"watchers_count":1437,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3554,"mirror_url":null,"archived":false,"open_issues_count":324,"license":null,"forks":3554,"open_issues":324,"watchers":1437,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757"},"html":{"href":"https://github.com/symfony/symfony-docs/pull/9757"},"issue":{"href":"https://api.github.com/repos/symfony/symfony-docs/issues/9757"},"comments":{"href":"https://api.github.com/repos/symfony/symfony-docs/issues/9757/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/9757/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony-docs/statuses/c9a625e3d2affb1c26f79de8e20fee91a1b13702"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"weaverryan"}}