{"action":"created","comment":{"url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments/201881797","pull_request_review_id":136470547,"id":201881797,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTg4MTc5Nw==","diff_hunk":"@@ -0,0 +1,218 @@\n+/*\n+ * Copyright 2018 the original author or authors.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.springframework.amqp.rabbit.listener;\n+\n+import java.util.Arrays;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+\n+import org.springframework.amqp.core.AnonymousQueue;\n+import org.springframework.amqp.core.Base64UrlNamingStrategy;\n+import org.springframework.amqp.core.Binding;\n+import org.springframework.amqp.core.BindingBuilder;\n+import org.springframework.amqp.core.Message;\n+import org.springframework.amqp.core.MessageListener;\n+import org.springframework.amqp.core.Queue;\n+import org.springframework.amqp.core.TopicExchange;\n+import org.springframework.amqp.rabbit.connection.Connection;\n+import org.springframework.amqp.rabbit.connection.ConnectionFactory;\n+import org.springframework.amqp.rabbit.connection.ConnectionListener;\n+import org.springframework.amqp.rabbit.core.RabbitAdmin;\n+import org.springframework.context.ApplicationEventPublisher;\n+import org.springframework.context.ApplicationEventPublisherAware;\n+import org.springframework.context.SmartLifecycle;\n+import org.springframework.lang.Nullable;\n+import org.springframework.util.Assert;\n+import org.springframework.util.ObjectUtils;\n+\n+/**\n+ * When the event-exchange-plugin is enabled (see\n+ * https://www.rabbitmq.com/event-exchange.html), if an object of this type is declared as\n+ * a bean, selected events will be published as {@link BrokerEvent}s. Such events can then\n+ * be consumed using an {@code ApplicationListener} or {@code @EventListener} method.\n+ * An {@link AnonymousQueue} will be bound to the {@code amq.rabbitmq.event} topic exchange\n+ * with the supplied keys.\n+ *\n+ * @author Gary Russell\n+ * @since 2.1\n+ *\n+ */\n+public class BrokerEventListener implements MessageListener, ApplicationEventPublisherAware, ConnectionListener,\n+\t\tSmartLifecycle {\n+\n+\tprivate static final Log logger = LogFactory.getLog(BrokerEventListener.class);\n+\n+\tprivate final AbstractMessageListenerContainer container;\n+\n+\tprivate final String[] eventKeys;\n+\n+\tprivate final RabbitAdmin admin;\n+\n+\tprivate final Queue eventQueue = new AnonymousQueue(new Base64UrlNamingStrategy(\"spring.events.\"));\n+\n+\tprivate final boolean ownContainer;\n+\n+\tprivate int phase;\n+\n+\tprivate boolean autoStartup = true;\n+\n+\tprivate boolean running;\n+\n+\tprivate boolean stopInvoked;\n+\n+\tprivate Exception bindingsFailedException;\n+\n+\tprivate ApplicationEventPublisher applicationEventPublisher;\n+\n+\t/**\n+\t * Construct an instance using the supplied connection factory and event keys. Event\n+\t * keys are patterns to match routing keys for events published to the\n+\t * {@code amq.rabbitmq.event} topic exchange. They can therefore match wildcards;\n+\t * examples are {@code user.#, queue.created}. Refer to the plugin documentation for\n+\t * information about available events. A single-threaded\n+\t * {@link DirectMessageListenerContainer} will be created; its lifecyle will be\n+\t * controlled by this object's {@link SmartLifecycle} methods.\n+\t * @param connectionFactory the connection factory.\n+\t * @param eventKeys the event keys.\n+\t */\n+\tpublic BrokerEventListener(ConnectionFactory connectionFactory, String... eventKeys) {\n+\t\tthis(new DirectMessageListenerContainer(connectionFactory), true, eventKeys);\n+\t}\n+\n+\t/**\n+\t * Construct an instance using the supplied listener container factory and event keys.\n+\t * Event keys are patterns to match routing keys for events published to the\n+\t * {@code amq.rabbitmq.event} topic exchange. They can therefore match wildcards;\n+\t * examples are {@code user.#, queue.created}. Refer to the plugin documentation for\n+\t * information about available events. The container's lifecyle will be not be","path":"spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/BrokerEventListener.java","position":102,"original_position":102,"commit_id":"5e28de057fe28ea05d3c1083d4843f41dd709489","original_commit_id":"5e28de057fe28ea05d3c1083d4843f41dd709489","user":{"login":"artembilan","id":1071590,"node_id":"MDQ6VXNlcjEwNzE1OTA=","avatar_url":"https://avatars3.githubusercontent.com/u/1071590?v=4","gravatar_id":"","url":"https://api.github.com/users/artembilan","html_url":"https://github.com/artembilan","followers_url":"https://api.github.com/users/artembilan/followers","following_url":"https://api.github.com/users/artembilan/following{/other_user}","gists_url":"https://api.github.com/users/artembilan/gists{/gist_id}","starred_url":"https://api.github.com/users/artembilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artembilan/subscriptions","organizations_url":"https://api.github.com/users/artembilan/orgs","repos_url":"https://api.github.com/users/artembilan/repos","events_url":"https://api.github.com/users/artembilan/events{/privacy}","received_events_url":"https://api.github.com/users/artembilan/received_events","type":"User","site_admin":false},"body":"DITTO","created_at":"2018-07-12T00:53:12Z","updated_at":"2018-07-12T00:58:46Z","html_url":"https://github.com/spring-projects/spring-amqp/pull/772#discussion_r201881797","pull_request_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments/201881797"},"html":{"href":"https://github.com/spring-projects/spring-amqp/pull/772#discussion_r201881797"},"pull_request":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772"}}},"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772","id":200514800,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNTE0ODAw","html_url":"https://github.com/spring-projects/spring-amqp/pull/772","diff_url":"https://github.com/spring-projects/spring-amqp/pull/772.diff","patch_url":"https://github.com/spring-projects/spring-amqp/pull/772.patch","issue_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/772","number":772,"state":"open","locked":false,"title":"AMQP-804: Add BrokerEventListener","user":{"login":"garyrussell","id":483832,"node_id":"MDQ6VXNlcjQ4MzgzMg==","avatar_url":"https://avatars3.githubusercontent.com/u/483832?v=4","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"body":"JIRA: https://jira.spring.io/browse/AMQP-804\r\n\r\nBind an auto-delete queue to the `amq.rabbitmq.events` exchange\r\nwith a configurable list of event keys.\r\n\r\nInitial commit.\r\n\r\nDocs/javadocs to follow after initial review.","created_at":"2018-07-10T20:31:19Z","updated_at":"2018-07-12T00:58:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1de0df085e1102a3402bedaf92021b8922f760a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772/commits","review_comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772/comments","review_comment_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/772/comments","statuses_url":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/5e28de057fe28ea05d3c1083d4843f41dd709489","head":{"label":"garyrussell:AMQP-804","ref":"AMQP-804","sha":"5e28de057fe28ea05d3c1083d4843f41dd709489","user":{"login":"garyrussell","id":483832,"node_id":"MDQ6VXNlcjQ4MzgzMg==","avatar_url":"https://avatars3.githubusercontent.com/u/483832?v=4","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"repo":{"id":3138424,"node_id":"MDEwOlJlcG9zaXRvcnkzMTM4NDI0","name":"spring-amqp","full_name":"garyrussell/spring-amqp","owner":{"login":"garyrussell","id":483832,"node_id":"MDQ6VXNlcjQ4MzgzMg==","avatar_url":"https://avatars3.githubusercontent.com/u/483832?v=4","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/garyrussell/spring-amqp","description":"Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ","fork":true,"url":"https://api.github.com/repos/garyrussell/spring-amqp","forks_url":"https://api.github.com/repos/garyrussell/spring-amqp/forks","keys_url":"https://api.github.com/repos/garyrussell/spring-amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/garyrussell/spring-amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/garyrussell/spring-amqp/teams","hooks_url":"https://api.github.com/repos/garyrussell/spring-amqp/hooks","issue_events_url":"https://api.github.com/repos/garyrussell/spring-amqp/issues/events{/number}","events_url":"https://api.github.com/repos/garyrussell/spring-amqp/events","assignees_url":"https://api.github.com/repos/garyrussell/spring-amqp/assignees{/user}","branches_url":"https://api.github.com/repos/garyrussell/spring-amqp/branches{/branch}","tags_url":"https://api.github.com/repos/garyrussell/spring-amqp/tags","blobs_url":"https://api.github.com/repos/garyrussell/spring-amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/garyrussell/spring-amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/garyrussell/spring-amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/garyrussell/spring-amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/garyrussell/spring-amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/garyrussell/spring-amqp/languages","stargazers_url":"https://api.github.com/repos/garyrussell/spring-amqp/stargazers","contributors_url":"https://api.github.com/repos/garyrussell/spring-amqp/contributors","subscribers_url":"https://api.github.com/repos/garyrussell/spring-amqp/subscribers","subscription_url":"https://api.github.com/repos/garyrussell/spring-amqp/subscription","commits_url":"https://api.github.com/repos/garyrussell/spring-amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/garyrussell/spring-amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/garyrussell/spring-amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/garyrussell/spring-amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/garyrussell/spring-amqp/contents/{+path}","compare_url":"https://api.github.com/repos/garyrussell/spring-amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/garyrussell/spring-amqp/merges","archive_url":"https://api.github.com/repos/garyrussell/spring-amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/garyrussell/spring-amqp/downloads","issues_url":"https://api.github.com/repos/garyrussell/spring-amqp/issues{/number}","pulls_url":"https://api.github.com/repos/garyrussell/spring-amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/garyrussell/spring-amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/garyrussell/spring-amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/garyrussell/spring-amqp/labels{/name}","releases_url":"https://api.github.com/repos/garyrussell/spring-amqp/releases{/id}","deployments_url":"https://api.github.com/repos/garyrussell/spring-amqp/deployments","created_at":"2012-01-09T17:21:18Z","updated_at":"2018-07-11T10:02:40Z","pushed_at":"2018-07-11T22:02:42Z","git_url":"git://github.com/garyrussell/spring-amqp.git","ssh_url":"git@github.com:garyrussell/spring-amqp.git","clone_url":"https://github.com/garyrussell/spring-amqp.git","svn_url":"https://github.com/garyrussell/spring-amqp","homepage":"http://www.springsource.org/spring-amqp","size":10131,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":1,"open_issues":0,"watchers":5,"default_branch":"master"}},"base":{"label":"spring-projects:master","ref":"master","sha":"5989d03f03c7b024c47276bec47d29abecd3c964","user":{"login":"spring-projects","id":317776,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzc3Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/317776?v=4","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"repo":{"id":1088796,"node_id":"MDEwOlJlcG9zaXRvcnkxMDg4Nzk2","name":"spring-amqp","full_name":"spring-projects/spring-amqp","owner":{"login":"spring-projects","id":317776,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzc3Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/317776?v=4","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spring-projects/spring-amqp","description":"Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ","fork":false,"url":"https://api.github.com/repos/spring-projects/spring-amqp","forks_url":"https://api.github.com/repos/spring-projects/spring-amqp/forks","keys_url":"https://api.github.com/repos/spring-projects/spring-amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spring-projects/spring-amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spring-projects/spring-amqp/teams","hooks_url":"https://api.github.com/repos/spring-projects/spring-amqp/hooks","issue_events_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/events{/number}","events_url":"https://api.github.com/repos/spring-projects/spring-amqp/events","assignees_url":"https://api.github.com/repos/spring-projects/spring-amqp/assignees{/user}","branches_url":"https://api.github.com/repos/spring-projects/spring-amqp/branches{/branch}","tags_url":"https://api.github.com/repos/spring-projects/spring-amqp/tags","blobs_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/spring-projects/spring-amqp/languages","stargazers_url":"https://api.github.com/repos/spring-projects/spring-amqp/stargazers","contributors_url":"https://api.github.com/repos/spring-projects/spring-amqp/contributors","subscribers_url":"https://api.github.com/repos/spring-projects/spring-amqp/subscribers","subscription_url":"https://api.github.com/repos/spring-projects/spring-amqp/subscription","commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/spring-projects/spring-amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/spring-projects/spring-amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/spring-projects/spring-amqp/contents/{+path}","compare_url":"https://api.github.com/repos/spring-projects/spring-amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spring-projects/spring-amqp/merges","archive_url":"https://api.github.com/repos/spring-projects/spring-amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spring-projects/spring-amqp/downloads","issues_url":"https://api.github.com/repos/spring-projects/spring-amqp/issues{/number}","pulls_url":"https://api.github.com/repos/spring-projects/spring-amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/spring-projects/spring-amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/spring-projects/spring-amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spring-projects/spring-amqp/labels{/name}","releases_url":"https://api.github.com/repos/spring-projects/spring-amqp/releases{/id}","deployments_url":"https://api.github.com/repos/spring-projects/spring-amqp/deployments","created_at":"2010-11-17T15:50:16Z","updated_at":"2018-07-11T15:03:12Z","pushed_at":"2018-07-11T23:21:51Z","git_url":"git://github.com/spring-projects/spring-amqp.git","ssh_url":"git@github.com:spring-projects/spring-amqp.git","clone_url":"https://github.com/spring-projects/spring-amqp.git","svn_url":"https://github.com/spring-projects/spring-amqp","homepage":"http://www.springsource.org/spring-amqp","size":10056,"stargazers_count":414,"watchers_count":414,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":360,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":360,"open_issues":6,"watchers":414,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772"},"html":{"href":"https://github.com/spring-projects/spring-amqp/pull/772"},"issue":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/issues/772"},"comments":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/issues/772/comments"},"review_comments":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772/comments"},"review_comment":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/pulls/772/commits"},"statuses":{"href":"https://api.github.com/repos/spring-projects/spring-amqp/statuses/5e28de057fe28ea05d3c1083d4843f41dd709489"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"artembilan"}}