GitHub PullRequestReviewCommentEvent at 2014-07-30 07:19:29
Repository: spring-integration
Actor: artembilan
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/15569264","id":15569264,"diff_hunk":"@@ -0,0 +1,140 @@\n+/*\n+ * Copyright 2013 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.integration.redis.outbound;\n+\n+import java.util.UUID;\n+import java.util.concurrent.TimeUnit;\n+\n+import org.springframework.data.redis.connection.RedisConnectionFactory;\n+import org.springframework.data.redis.core.BoundListOperations;\n+import org.springframework.data.redis.core.RedisTemplate;\n+import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;\n+import org.springframework.data.redis.serializer.RedisSerializer;\n+import org.springframework.data.redis.serializer.StringRedisSerializer;\n+import org.springframework.expression.EvaluationContext;\n+import org.springframework.expression.Expression;\n+import org.springframework.expression.common.LiteralExpression;\n+import org.springframework.integration.expression.IntegrationEvaluationContextAware;\n+import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;\n+import org.springframework.integration.redis.util.SerializerUtil;\n+import org.springframework.messaging.Message;\n+import org.springframework.util.Assert;\n+\n+/**\n+ * @author David Liu\n+ * @since 4.1\n+ */\n+public class RedisQueueOutboundGateway extends AbstractReplyProducingMessageHandler implements IntegrationEvaluationContextAware {\n+\n+\tprivate final RedisTemplate<String, Object> template;\n+\n+\tprivate final Expression queueNameExpression;\n+\n+\tprivate volatile EvaluationContext evaluationContext;\n+\n+\tprivate volatile boolean extractPayload = true;\n+\n+\tprivate volatile RedisSerializer<?> serializer = new JdkSerializationRedisSerializer();\n+\n+\tprivate volatile boolean serializerExplicitlySet;\n+\t\n+\tprivate static final int TIMEOUT = 1000;\n+\t\n+\tprivate volatile int timeout = TIMEOUT;\n+\t\n+\tprivate static final String MESSAGESUFFIX = \".reply\";\n+\t\n+\tprivate volatile boolean expectReply;\n+\t\n+\tprivate BoundListOperations<String, Object> boundListOperations = null;\n+\t\n+\tpublic RedisQueueOutboundGateway(String queueName, RedisConnectionFactory connectionFactory) {\n+\t\tthis(new LiteralExpression(queueName), connectionFactory);\n+\t}\n+\n+\tpublic RedisQueueOutboundGateway(Expression queueNameExpression, RedisConnectionFactory connectionFactory) {\n+\t\tAssert.notNull(queueNameExpression, \"'queueNameExpression' is required\");\n+\t\tAssert.hasText(queueNameExpression.getExpressionString(), \"'queueNameExpression.getExpressionString()' is required\");\n+\t\tAssert.notNull(connectionFactory, \"'connectionFactory' must not be null\");\n+\t\tthis.queueNameExpression = queueNameExpression;\n+\t\tthis.template = new RedisTemplate<String, Object>();\n+\t\tthis.template.setConnectionFactory(connectionFactory);\n+\t\tthis.template.setEnableDefaultSerializer(false);\n+\t\tthis.template.setKeySerializer(new StringRedisSerializer());\n+\t\tthis.template.afterPropertiesSet();\n+\t}\n+\t\n+\tpublic void setTimeout(int timeout) {\n+\t\tthis.timeout = timeout;\n+\t}\n+\n+\tpublic void setExpectReply(boolean expectReply) {\n+\t\tthis.expectReply = expectReply;\n+\t}\n+\t\n+\t@Override\n+\tpublic void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {\n+\t\tthis.evaluationContext = evaluationContext;\n+\t}\n+\n+\tpublic void setExtractPayload(boolean extractPayload) {\n+\t\tthis.extractPayload = extractPayload;\n+\t}\n+\n+\tpublic void setSerializer(RedisSerializer<?> serializer) {\n+\t\tAssert.notNull(serializer, \"'serializer' must not be null\");\n+\t\tthis.serializer = serializer;\n+\t\tthis.serializerExplicitlySet = true;\n+\t}\n+\n+\t@Override\n+\tpublic String getComponentType() {\n+\t\treturn \"redis:queue-outbound-gatewway\";\n+\t}\n+\n+\t@Override\n+\tprotected Object handleRequestMessage(Message<?> message) {\n+\t\tObject value = message;\n+\n+\t\tif (this.extractPayload) {\n+\t\t\tvalue = message.getPayload();\n+\t\t}\n+\t\tvalue = SerializerUtil.serialize(value, this.serializerExplicitlySet, this.serializer);\n+\t\tString queueName = this.queueNameExpression.getValue(this.evaluationContext, message, String.class);\n+\n+\t\tif (this.expectReply) {\n+\t\t\tlong uuid = generateRandomUUID();\n+\t\t\tthis.template.boundListOps(queueName).leftPush(SerializerUtil.serialize(uuid+\"\", this.serializerExplicitlySet, this.serializer));\n+\t\t\tthis.template.boundListOps(uuid + \"\").leftPush(value);\n+\t\t\tthis.boundListOperations = template.boundListOps(uuid + MESSAGESUFFIX);\n+\t\t\tbyte[] reply = (byte[]) this.boundListOperations.rightPop(this.timeout, TimeUnit.MILLISECONDS);\n+\t\t\tObject replyMessage = this.serializer.deserialize(reply);\n+\t\t\tif (replyMessage == null) {\n+\t\t\t\treturn null;\n+\t\t\t}\n+\t\t\treturn this.getMessageBuilderFactory().withPayload(replyMessage).build();\n+\t\t}\n+\t\telse {\n+\t\t\tthis.template.boundListOps(queueName).leftPush(value);\n+\t\t\treturn null;\n+\t\t}","path":"spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisQueueOutboundGateway.java","position":134,"original_position":134,"commit_id":"48fd36531b28408ecc5f29c234532a4ddd2298b7","original_commit_id":"48fd36531b28408ecc5f29c234532a4ddd2298b7","user":{"login":"artembilan","id":1071590,"avatar_url":"https://avatars.githubusercontent.com/u/1071590?v=1","gravatar_id":"c3d7e967be8fcc46780cd3dfcdc6cba9","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":"As I said before: `RedisQueueOutboundGateway` is used only for the `two-way`, `request-reply` interaction.\r\nThe `expectReply` is redundant and useless property. \r\nAvoiding it you get the simpler code here.","created_at":"2014-07-30T07:19:29Z","updated_at":"2014-07-30T07:19:29Z","html_url":"https://github.com/spring-projects/spring-integration/pull/1230#discussion_r15569264","pull_request_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230","_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/15569264"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1230#discussion_r15569264"},"pull_request":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230"}}},"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230","id":19060970,"html_url":"https://github.com/spring-projects/spring-integration/pull/1230","diff_url":"https://github.com/spring-projects/spring-integration/pull/1230.diff","patch_url":"https://github.com/spring-projects/spring-integration/pull/1230.patch","issue_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1230","number":1230,"state":"open","title":"Int3341","user":{"login":"liujiong1982","id":7462724,"avatar_url":"https://avatars.githubusercontent.com/u/7462724?v=1","gravatar_id":"446c719d03b92d723bf5903300f824ef","url":"https://api.github.com/users/liujiong1982","html_url":"https://github.com/liujiong1982","followers_url":"https://api.github.com/users/liujiong1982/followers","following_url":"https://api.github.com/users/liujiong1982/following{/other_user}","gists_url":"https://api.github.com/users/liujiong1982/gists{/gist_id}","starred_url":"https://api.github.com/users/liujiong1982/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liujiong1982/subscriptions","organizations_url":"https://api.github.com/users/liujiong1982/orgs","repos_url":"https://api.github.com/users/liujiong1982/repos","events_url":"https://api.github.com/users/liujiong1982/events{/privacy}","received_events_url":"https://api.github.com/users/liujiong1982/received_events","type":"User","site_admin":false},"body":"Add redisqueueoutboundgateway and redisqueueinboundgateway","created_at":"2014-07-29T23:08:12Z","updated_at":"2014-07-30T07:19:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0dcf9dfb358a03d1fa28fa9400c045d9f2178f7b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230/commits","review_comments_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230/comments","review_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/{number}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1230/comments","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/48fd36531b28408ecc5f29c234532a4ddd2298b7","head":{"label":"liujiong1982:INT3341","ref":"INT3341","sha":"48fd36531b28408ecc5f29c234532a4ddd2298b7","user":{"login":"liujiong1982","id":7462724,"avatar_url":"https://avatars.githubusercontent.com/u/7462724?v=1","gravatar_id":"446c719d03b92d723bf5903300f824ef","url":"https://api.github.com/users/liujiong1982","html_url":"https://github.com/liujiong1982","followers_url":"https://api.github.com/users/liujiong1982/followers","following_url":"https://api.github.com/users/liujiong1982/following{/other_user}","gists_url":"https://api.github.com/users/liujiong1982/gists{/gist_id}","starred_url":"https://api.github.com/users/liujiong1982/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liujiong1982/subscriptions","organizations_url":"https://api.github.com/users/liujiong1982/orgs","repos_url":"https://api.github.com/users/liujiong1982/repos","events_url":"https://api.github.com/users/liujiong1982/events{/privacy}","received_events_url":"https://api.github.com/users/liujiong1982/received_events","type":"User","site_admin":false},"repo":{"id":20980209,"name":"spring-integration","full_name":"liujiong1982/spring-integration","owner":{"login":"liujiong1982","id":7462724,"avatar_url":"https://avatars.githubusercontent.com/u/7462724?v=1","gravatar_id":"446c719d03b92d723bf5903300f824ef","url":"https://api.github.com/users/liujiong1982","html_url":"https://github.com/liujiong1982","followers_url":"https://api.github.com/users/liujiong1982/followers","following_url":"https://api.github.com/users/liujiong1982/following{/other_user}","gists_url":"https://api.github.com/users/liujiong1982/gists{/gist_id}","starred_url":"https://api.github.com/users/liujiong1982/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liujiong1982/subscriptions","organizations_url":"https://api.github.com/users/liujiong1982/orgs","repos_url":"https://api.github.com/users/liujiong1982/repos","events_url":"https://api.github.com/users/liujiong1982/events{/privacy}","received_events_url":"https://api.github.com/users/liujiong1982/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liujiong1982/spring-integration","description":"Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)","fork":true,"url":"https://api.github.com/repos/liujiong1982/spring-integration","forks_url":"https://api.github.com/repos/liujiong1982/spring-integration/forks","keys_url":"https://api.github.com/repos/liujiong1982/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liujiong1982/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liujiong1982/spring-integration/teams","hooks_url":"https://api.github.com/repos/liujiong1982/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/liujiong1982/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/liujiong1982/spring-integration/events","assignees_url":"https://api.github.com/repos/liujiong1982/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/liujiong1982/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/liujiong1982/spring-integration/tags","blobs_url":"https://api.github.com/repos/liujiong1982/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liujiong1982/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liujiong1982/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/liujiong1982/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liujiong1982/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/liujiong1982/spring-integration/languages","stargazers_url":"https://api.github.com/repos/liujiong1982/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/liujiong1982/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/liujiong1982/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/liujiong1982/spring-integration/subscription","commits_url":"https://api.github.com/repos/liujiong1982/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/liujiong1982/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/liujiong1982/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/liujiong1982/spring-integration/issues/comments/{number}","contents_url":"https://api.github.com/repos/liujiong1982/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/liujiong1982/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liujiong1982/spring-integration/merges","archive_url":"https://api.github.com/repos/liujiong1982/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liujiong1982/spring-integration/downloads","issues_url":"https://api.github.com/repos/liujiong1982/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/liujiong1982/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/liujiong1982/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/liujiong1982/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liujiong1982/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/liujiong1982/spring-integration/releases{/id}","created_at":"2014-06-18T22:30:30Z","updated_at":"2014-07-17T05:38:47Z","pushed_at":"2014-07-30T02:17:58Z","git_url":"git://github.com/liujiong1982/spring-integration.git","ssh_url":"git@github.com:liujiong1982/spring-integration.git","clone_url":"https://github.com/liujiong1982/spring-integration.git","svn_url":"https://github.com/liujiong1982/spring-integration","homepage":"http://projects.spring.io/spring-integration/","size":29149,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"spring-projects:master","ref":"master","sha":"48ea677b41dab4e41b3358c037dbbc79ed6fdd92","user":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=1","gravatar_id":"6f8a529bd100f4272a9ff1b8cdfbd26e","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":2090979,"name":"spring-integration","full_name":"spring-projects/spring-integration","owner":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=1","gravatar_id":"6f8a529bd100f4272a9ff1b8cdfbd26e","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-integration","description":"Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)","fork":false,"url":"https://api.github.com/repos/spring-projects/spring-integration","forks_url":"https://api.github.com/repos/spring-projects/spring-integration/forks","keys_url":"https://api.github.com/repos/spring-projects/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spring-projects/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spring-projects/spring-integration/teams","hooks_url":"https://api.github.com/repos/spring-projects/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/spring-projects/spring-integration/events","assignees_url":"https://api.github.com/repos/spring-projects/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/spring-projects/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/spring-projects/spring-integration/tags","blobs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spring-projects/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/spring-projects/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/spring-projects/spring-integration/languages","stargazers_url":"https://api.github.com/repos/spring-projects/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/spring-projects/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/spring-projects/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/spring-projects/spring-integration/subscription","commits_url":"https://api.github.com/repos/spring-projects/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/spring-projects/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/comments/{number}","contents_url":"https://api.github.com/repos/spring-projects/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/spring-projects/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spring-projects/spring-integration/merges","archive_url":"https://api.github.com/repos/spring-projects/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spring-projects/spring-integration/downloads","issues_url":"https://api.github.com/repos/spring-projects/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/spring-projects/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/spring-projects/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spring-projects/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/spring-projects/spring-integration/releases{/id}","created_at":"2011-07-22T21:47:27Z","updated_at":"2014-07-27T19:29:31Z","pushed_at":"2014-07-29T15:15:31Z","git_url":"git://github.com/spring-projects/spring-integration.git","ssh_url":"git@github.com:spring-projects/spring-integration.git","clone_url":"https://github.com/spring-projects/spring-integration.git","svn_url":"https://github.com/spring-projects/spring-integration","homepage":"http://projects.spring.io/spring-integration/","size":79517,"stargazers_count":266,"watchers_count":266,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":236,"mirror_url":null,"open_issues_count":9,"forks":236,"open_issues":9,"watchers":266,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1230"},"issue":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1230"},"comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1230/comments"},"review_comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230/comments"},"review_comment":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1230/commits"},"statuses":{"href":"https://api.github.com/repos/spring-projects/spring-integration/statuses/48fd36531b28408ecc5f29c234532a4ddd2298b7"}}}}