{"action":"created","comment":{"url":"https://api.github.com/repos/Workiva/frugal/pulls/comments/238405990","pull_request_review_id":180940204,"id":238405990,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODQwNTk5MA==","diff_hunk":"@@ -0,0 +1,234 @@\n+# Copyright 2017 Workiva\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+#     http://www.apache.org/licenses/LICENSE-2.0\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+import inspect\n+from uuid import uuid4\n+\n+from stomp import Connection\n+from stomp import ConnectionListener\n+from thrift.transport.TTransport import TMemoryBuffer\n+from thrift.transport.TTransport import TTransportException\n+\n+from frugal.exceptions import TTransportExceptionType\n+from frugal.transport import FPublisherTransport\n+from frugal.transport import FPublisherTransportFactory\n+from frugal.transport import FSubscriberTransport\n+from frugal.transport import FSubscriberTransportFactory\n+\n+\n+FRUGAL_PREFIX = 'frugal.'\n+\n+\n+class FStompPublisherTransportFactory(FPublisherTransportFactory):\n+    \"\"\"\n+    FStompPublisherTransportFactory is used to create\n+    FStompPublisherTransports.\n+    \"\"\"\n+\n+    def __init__(self, stomp_conn: Connection, topic_prefix: str,\n+                 max_message_size: int = 32 * 1024 * 1024):\n+        self._stomp_conn = stomp_conn\n+        self._topic_prefix = topic_prefix\n+        self._max_message_size = max_message_size\n+\n+    def get_transport(self) -> FPublisherTransport:\n+        \"\"\"\n+        Get a new FStompPublisherTransport.\n+        \"\"\"\n+        return FStompPublisherTransport(\n+            self._stomp_conn, self._topic_prefix, self._max_message_size)\n+\n+\n+class FStompPublisherTransport(FPublisherTransport):\n+    \"\"\"\n+    FStompPublisherTransport is used exclusively for pub/sub scopes.\n+    Publishers use it to publish to a topic. Messaging brokers that support\n+    stomp protocol can be used as the underlying bus.\n+    \"\"\"\n+\n+    def __init__(self, stomp_conn: Connection, topic_prefix: str,\n+                 max_message_size: int):\n+        super().__init__(max_message_size)\n+        self._stomp_conn = stomp_conn\n+        self._topic_prefix = topic_prefix\n+\n+    async def open(self):\n+        \"\"\"\n+        Open the stomp publisher in preparation for publishing.\n+        \"\"\"\n+        if not self._stomp_conn.is_connected():\n+            raise TTransportException(TTransportException.NOT_OPEN,\n+                                      'stomp connection is not connected')\n+\n+    async def close(self):\n+        \"\"\"\n+        Close the stomp publisher transport and disconnect from the stomp\n+        broker.\n+        :return:\n+        \"\"\"\n+        if not self.is_open():\n+            return\n+\n+        await self._stomp_conn.disconnect()\n+\n+    def is_open(self) -> bool:\n+        \"\"\"\n+        Check to see if the transport is open.\n+        \"\"\"\n+        return self._stomp_conn.is_connected()\n+\n+    async def publish(self, topic: str, data):\n+        \"\"\"\n+        Publish a message to stomp broker on a given topic.\n+\n+        Args:\n+            topic: string\n+            data: bytearray\n+        \"\"\"\n+        if not self.is_open():\n+            raise TTransportException(\n+                type=TTransportExceptionType.NOT_OPEN,\n+                message='Transport is not connected')\n+        if self._check_publish_size(data):\n+            raise TTransportException(\n+                type=TTransportExceptionType.REQUEST_TOO_LARGE,\n+                message='Message exceeds max message size'\n+            )\n+        destination = '/topic/{topic_prefix}{frugal_prefix}{topic}'.format(\n+            topic_prefix=self._topic_prefix,\n+            frugal_prefix=FRUGAL_PREFIX,\n+            topic=topic\n+        )\n+        await self._stomp_conn.send(destination,\n+                                    data,\n+                                    content_type='application/octet-stream',\n+                                    headers={'persistent': 'true'})\n+\n+\n+class FStompSubscriberTransportFactory(FSubscriberTransportFactory):\n+    \"\"\"\n+    FStompSubscriberTransportFactory is used to create\n+    FStompSubscriberTransports.\n+    \"\"\"\n+\n+    def __init__(self, stomp_conn: Connection, consumer_prefix: str,\n+                 use_queue: bool):","path":"lib/python/frugal/aio/transport/stomp_transport.py","position":null,"original_position":123,"commit_id":"1cbf7abc29e094b1005325b3e0fec589195f02d8","original_commit_id":"67cd60ad28f2ca1e16b7a53f934934b237e8e534","user":{"login":"yuanmwang-wf","id":15874803,"node_id":"MDQ6VXNlcjE1ODc0ODAz","avatar_url":"https://avatars1.githubusercontent.com/u/15874803?v=4","gravatar_id":"","url":"https://api.github.com/users/yuanmwang-wf","html_url":"https://github.com/yuanmwang-wf","followers_url":"https://api.github.com/users/yuanmwang-wf/followers","following_url":"https://api.github.com/users/yuanmwang-wf/following{/other_user}","gists_url":"https://api.github.com/users/yuanmwang-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/yuanmwang-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuanmwang-wf/subscriptions","organizations_url":"https://api.github.com/users/yuanmwang-wf/orgs","repos_url":"https://api.github.com/users/yuanmwang-wf/repos","events_url":"https://api.github.com/users/yuanmwang-wf/events{/privacy}","received_events_url":"https://api.github.com/users/yuanmwang-wf/received_events","type":"User","site_admin":false},"body":"I've added a default value for `use_queue`, I can't think of a sane default value for `consumer_prefix` though since it would be like `Consumer.A.` and I don't think there's a good default value for the 'A' part. ","created_at":"2018-12-03T19:30:38Z","updated_at":"2018-12-03T19:30:38Z","html_url":"https://github.com/Workiva/frugal/pull/1055#discussion_r238405990","pull_request_url":"https://api.github.com/repos/Workiva/frugal/pulls/1055","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/comments/238405990"},"html":{"href":"https://github.com/Workiva/frugal/pull/1055#discussion_r238405990"},"pull_request":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/1055"}},"in_reply_to_id":237099652},"pull_request":{"url":"https://api.github.com/repos/Workiva/frugal/pulls/1055","id":234037251,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0MDM3MjUx","html_url":"https://github.com/Workiva/frugal/pull/1055","diff_url":"https://github.com/Workiva/frugal/pull/1055.diff","patch_url":"https://github.com/Workiva/frugal/pull/1055.patch","issue_url":"https://api.github.com/repos/Workiva/frugal/issues/1055","number":1055,"state":"open","locked":false,"title":"INFENG-6369: python asyncio activemq frugal transport","user":{"login":"yuanmwang-wf","id":15874803,"node_id":"MDQ6VXNlcjE1ODc0ODAz","avatar_url":"https://avatars1.githubusercontent.com/u/15874803?v=4","gravatar_id":"","url":"https://api.github.com/users/yuanmwang-wf","html_url":"https://github.com/yuanmwang-wf","followers_url":"https://api.github.com/users/yuanmwang-wf/followers","following_url":"https://api.github.com/users/yuanmwang-wf/following{/other_user}","gists_url":"https://api.github.com/users/yuanmwang-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/yuanmwang-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuanmwang-wf/subscriptions","organizations_url":"https://api.github.com/users/yuanmwang-wf/orgs","repos_url":"https://api.github.com/users/yuanmwang-wf/repos","events_url":"https://api.github.com/users/yuanmwang-wf/events{/privacy}","received_events_url":"https://api.github.com/users/yuanmwang-wf/received_events","type":"User","site_admin":false},"body":"**Overview**\r\nSimilar to how activemq transport is implemented in go and java, the transport uses connections created by [stomp.py](https://github.com/jasonrbriggs/stomp.py) to communicate with the broker.\r\n\r\n**Reviewers**\r\n@Workiva/product2\r\n","created_at":"2018-11-27T19:44:55Z","updated_at":"2018-12-03T19:30:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1b0ed4bd35cecd523e03f11876c42cac05721fd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":457775098,"node_id":"MDU6TGFiZWw0NTc3NzUwOTg=","url":"https://api.github.com/repos/Workiva/frugal/labels/Merge%20Requirements%20Unmet","name":"Merge Requirements Unmet","color":"e11d21","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Workiva/frugal/pulls/1055/commits","review_comments_url":"https://api.github.com/repos/Workiva/frugal/pulls/1055/comments","review_comment_url":"https://api.github.com/repos/Workiva/frugal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Workiva/frugal/issues/1055/comments","statuses_url":"https://api.github.com/repos/Workiva/frugal/statuses/1cbf7abc29e094b1005325b3e0fec589195f02d8","head":{"label":"yuanmwang-wf:Infeng-6369","ref":"Infeng-6369","sha":"1cbf7abc29e094b1005325b3e0fec589195f02d8","user":{"login":"yuanmwang-wf","id":15874803,"node_id":"MDQ6VXNlcjE1ODc0ODAz","avatar_url":"https://avatars1.githubusercontent.com/u/15874803?v=4","gravatar_id":"","url":"https://api.github.com/users/yuanmwang-wf","html_url":"https://github.com/yuanmwang-wf","followers_url":"https://api.github.com/users/yuanmwang-wf/followers","following_url":"https://api.github.com/users/yuanmwang-wf/following{/other_user}","gists_url":"https://api.github.com/users/yuanmwang-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/yuanmwang-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuanmwang-wf/subscriptions","organizations_url":"https://api.github.com/users/yuanmwang-wf/orgs","repos_url":"https://api.github.com/users/yuanmwang-wf/repos","events_url":"https://api.github.com/users/yuanmwang-wf/events{/privacy}","received_events_url":"https://api.github.com/users/yuanmwang-wf/received_events","type":"User","site_admin":false},"repo":{"id":151319376,"node_id":"MDEwOlJlcG9zaXRvcnkxNTEzMTkzNzY=","name":"frugal","full_name":"yuanmwang-wf/frugal","private":false,"owner":{"login":"yuanmwang-wf","id":15874803,"node_id":"MDQ6VXNlcjE1ODc0ODAz","avatar_url":"https://avatars1.githubusercontent.com/u/15874803?v=4","gravatar_id":"","url":"https://api.github.com/users/yuanmwang-wf","html_url":"https://github.com/yuanmwang-wf","followers_url":"https://api.github.com/users/yuanmwang-wf/followers","following_url":"https://api.github.com/users/yuanmwang-wf/following{/other_user}","gists_url":"https://api.github.com/users/yuanmwang-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/yuanmwang-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuanmwang-wf/subscriptions","organizations_url":"https://api.github.com/users/yuanmwang-wf/orgs","repos_url":"https://api.github.com/users/yuanmwang-wf/repos","events_url":"https://api.github.com/users/yuanmwang-wf/events{/privacy}","received_events_url":"https://api.github.com/users/yuanmwang-wf/received_events","type":"User","site_admin":false},"html_url":"https://github.com/yuanmwang-wf/frugal","description":"Thrift improved","fork":true,"url":"https://api.github.com/repos/yuanmwang-wf/frugal","forks_url":"https://api.github.com/repos/yuanmwang-wf/frugal/forks","keys_url":"https://api.github.com/repos/yuanmwang-wf/frugal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuanmwang-wf/frugal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuanmwang-wf/frugal/teams","hooks_url":"https://api.github.com/repos/yuanmwang-wf/frugal/hooks","issue_events_url":"https://api.github.com/repos/yuanmwang-wf/frugal/issues/events{/number}","events_url":"https://api.github.com/repos/yuanmwang-wf/frugal/events","assignees_url":"https://api.github.com/repos/yuanmwang-wf/frugal/assignees{/user}","branches_url":"https://api.github.com/repos/yuanmwang-wf/frugal/branches{/branch}","tags_url":"https://api.github.com/repos/yuanmwang-wf/frugal/tags","blobs_url":"https://api.github.com/repos/yuanmwang-wf/frugal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuanmwang-wf/frugal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuanmwang-wf/frugal/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuanmwang-wf/frugal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuanmwang-wf/frugal/statuses/{sha}","languages_url":"https://api.github.com/repos/yuanmwang-wf/frugal/languages","stargazers_url":"https://api.github.com/repos/yuanmwang-wf/frugal/stargazers","contributors_url":"https://api.github.com/repos/yuanmwang-wf/frugal/contributors","subscribers_url":"https://api.github.com/repos/yuanmwang-wf/frugal/subscribers","subscription_url":"https://api.github.com/repos/yuanmwang-wf/frugal/subscription","commits_url":"https://api.github.com/repos/yuanmwang-wf/frugal/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuanmwang-wf/frugal/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuanmwang-wf/frugal/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuanmwang-wf/frugal/issues/comments{/number}","contents_url":"https://api.github.com/repos/yuanmwang-wf/frugal/contents/{+path}","compare_url":"https://api.github.com/repos/yuanmwang-wf/frugal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuanmwang-wf/frugal/merges","archive_url":"https://api.github.com/repos/yuanmwang-wf/frugal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuanmwang-wf/frugal/downloads","issues_url":"https://api.github.com/repos/yuanmwang-wf/frugal/issues{/number}","pulls_url":"https://api.github.com/repos/yuanmwang-wf/frugal/pulls{/number}","milestones_url":"https://api.github.com/repos/yuanmwang-wf/frugal/milestones{/number}","notifications_url":"https://api.github.com/repos/yuanmwang-wf/frugal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuanmwang-wf/frugal/labels{/name}","releases_url":"https://api.github.com/repos/yuanmwang-wf/frugal/releases{/id}","deployments_url":"https://api.github.com/repos/yuanmwang-wf/frugal/deployments","created_at":"2018-10-02T20:32:09Z","updated_at":"2018-10-02T20:32:13Z","pushed_at":"2018-12-03T18:32:38Z","git_url":"git://github.com/yuanmwang-wf/frugal.git","ssh_url":"git@github.com:yuanmwang-wf/frugal.git","clone_url":"https://github.com/yuanmwang-wf/frugal.git","svn_url":"https://github.com/yuanmwang-wf/frugal","homepage":"","size":40265,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Workiva:amazon-mq","ref":"amazon-mq","sha":"f5ff2421affbadf21e95c6be2084ce01fd78a86f","user":{"login":"Workiva","id":1087529,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODc1Mjk=","avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":42115613,"node_id":"MDEwOlJlcG9zaXRvcnk0MjExNTYxMw==","name":"frugal","full_name":"Workiva/frugal","private":false,"owner":{"login":"Workiva","id":1087529,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODc1Mjk=","avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Workiva/frugal","description":"Thrift improved","fork":false,"url":"https://api.github.com/repos/Workiva/frugal","forks_url":"https://api.github.com/repos/Workiva/frugal/forks","keys_url":"https://api.github.com/repos/Workiva/frugal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/frugal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/frugal/teams","hooks_url":"https://api.github.com/repos/Workiva/frugal/hooks","issue_events_url":"https://api.github.com/repos/Workiva/frugal/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/frugal/events","assignees_url":"https://api.github.com/repos/Workiva/frugal/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/frugal/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/frugal/tags","blobs_url":"https://api.github.com/repos/Workiva/frugal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/frugal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/frugal/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/frugal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/frugal/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/frugal/languages","stargazers_url":"https://api.github.com/repos/Workiva/frugal/stargazers","contributors_url":"https://api.github.com/repos/Workiva/frugal/contributors","subscribers_url":"https://api.github.com/repos/Workiva/frugal/subscribers","subscription_url":"https://api.github.com/repos/Workiva/frugal/subscription","commits_url":"https://api.github.com/repos/Workiva/frugal/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/frugal/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/frugal/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/frugal/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/frugal/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/frugal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/frugal/merges","archive_url":"https://api.github.com/repos/Workiva/frugal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/frugal/downloads","issues_url":"https://api.github.com/repos/Workiva/frugal/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/frugal/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/frugal/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/frugal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/frugal/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/frugal/releases{/id}","deployments_url":"https://api.github.com/repos/Workiva/frugal/deployments","created_at":"2015-09-08T13:58:59Z","updated_at":"2018-11-30T13:00:36Z","pushed_at":"2018-12-03T18:32:39Z","git_url":"git://github.com/Workiva/frugal.git","ssh_url":"git@github.com:Workiva/frugal.git","clone_url":"https://github.com/Workiva/frugal.git","svn_url":"https://github.com/Workiva/frugal","homepage":"","size":40483,"stargazers_count":63,"watchers_count":63,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":43,"open_issues":18,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/1055"},"html":{"href":"https://github.com/Workiva/frugal/pull/1055"},"issue":{"href":"https://api.github.com/repos/Workiva/frugal/issues/1055"},"comments":{"href":"https://api.github.com/repos/Workiva/frugal/issues/1055/comments"},"review_comments":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/1055/comments"},"review_comment":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Workiva/frugal/pulls/1055/commits"},"statuses":{"href":"https://api.github.com/repos/Workiva/frugal/statuses/1cbf7abc29e094b1005325b3e0fec589195f02d8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"yuanmwang-wf"}}