{"action":"opened","number":102,"pull_request":{"url":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102","id":209712643,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5NzEyNjQz","html_url":"https://github.com/apache/rocketmq-externals/pull/102","diff_url":"https://github.com/apache/rocketmq-externals/pull/102.diff","patch_url":"https://github.com/apache/rocketmq-externals/pull/102.patch","issue_url":"https://api.github.com/repos/apache/rocketmq-externals/issues/102","number":102,"state":"open","locked":false,"title":"[ISSUE 101] New Feature: support sending transactional message with rocketmq-spring-boot-starter","user":{"login":"walking98","id":19318111,"node_id":"MDQ6VXNlcjE5MzE4MTEx","avatar_url":"https://avatars2.githubusercontent.com/u/19318111?v=4","gravatar_id":"","url":"https://api.github.com/users/walking98","html_url":"https://github.com/walking98","followers_url":"https://api.github.com/users/walking98/followers","following_url":"https://api.github.com/users/walking98/following{/other_user}","gists_url":"https://api.github.com/users/walking98/gists{/gist_id}","starred_url":"https://api.github.com/users/walking98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walking98/subscriptions","organizations_url":"https://api.github.com/users/walking98/orgs","repos_url":"https://api.github.com/users/walking98/repos","events_url":"https://api.github.com/users/walking98/events{/privacy}","received_events_url":"https://api.github.com/users/walking98/received_events","type":"User","site_admin":false},"body":"## What is the purpose of the change\r\n\r\nRocketMQ has supported the transaction message in version 4.4.0, but the rocketmq-spring-boot-starter has no the related support yet.\r\n\r\n## Brief changelog\r\n\r\nXX\r\n\r\n## Verifying this change\r\n\r\nTested it with a spring-boot application, main logic at the following:\r\n1.  Producer side:\r\n@SpringBootApplication\r\npublic class ProducerApplication implements CommandLineRunner {\r\n    @Resource\r\n    private RocketMQTemplate rocketMQTemplate;\r\n\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(ProducerApplication.class, args);\r\n    }\r\n\r\n    @Override\r\n    public void run(String... args) throws Exception {\r\n        testTransaction();\r\n    }\r\n\r\n\r\n    private void testTransaction() throws MQClientException {\r\n        String producerName = \"txTest\";\r\n        rocketMQTemplate.createAndStartTransactionMQProducer(producerName,\r\n            new TransactionListenerImpl(),\r\n            new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() {\r\n                @Override\r\n                public Thread newThread(Runnable r) {\r\n                    Thread thread = new Thread(r);\r\n                    thread.setName(\"client-transaction-msg-check-thread\");\r\n                    return thread;\r\n                }\r\n            }));\r\n\r\n        String[] tags = new String[] {\"TagA\", \"TagB\", \"TagC\", \"TagD\", \"TagE\"};\r\n        for (int i = 0; i < 10; i++) {\r\n            try {\r\n\r\n                org.apache.rocketmq.common.message.Message msg =\r\n                    new org.apache.rocketmq.common.message.Message(\"string-topic\", tags[i % tags.length], \"KEY\" + i,\r\n                        (\"Hello RocketMQ \" + i).getBytes(RemotingHelper.DEFAULT_CHARSET));\r\n                System.out.printf(\"send msg body = %s%n\",new String(msg.getBody()));\r\n                SendResult sendResult = rocketMQTemplate.sendMessageInTransaction(producerName, msg, null);\r\n                System.out.printf(\"XXXXX:   %s%n\", sendResult);\r\n\r\n                Thread.sleep(10);\r\n            } catch (Exception e) {\r\n                e.printStackTrace();\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n    class TransactionListenerImpl implements TransactionListener {\r\n        private AtomicInteger transactionIndex = new AtomicInteger(0);\r\n\r\n        private ConcurrentHashMap<String, Integer> localTrans = new ConcurrentHashMap<String, Integer>();\r\n\r\n        @Override\r\n        public LocalTransactionState executeLocalTransaction(Message msg, Object arg) {\r\n            int value = transactionIndex.getAndIncrement();\r\n            int status = value % 3;\r\n            localTrans.put(msg.getTransactionId(), status);\r\n            return LocalTransactionState.UNKNOW;\r\n        }\r\n\r\n        @Override\r\n        public LocalTransactionState checkLocalTransaction(MessageExt msg) {\r\n            Integer status = localTrans.get(msg.getTransactionId());\r\n            if (null != status) {\r\n                switch (status) {\r\n                    case 0:\r\n                        return LocalTransactionState.UNKNOW;\r\n                    case 1:\r\n                        return LocalTransactionState.COMMIT_MESSAGE;\r\n                    case 2:\r\n                        return LocalTransactionState.ROLLBACK_MESSAGE;\r\n                }\r\n            }\r\n            return LocalTransactionState.COMMIT_MESSAGE;\r\n        }\r\n    }\r\n\r\n}\r\n\r\n2. Consumer Side:\r\n@SpringBootApplication\r\npublic class ConsumerApplication {\r\n\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(ConsumerApplication.class, args);\r\n    }\r\n}\r\n\r\n\r\n@Slf4j\r\n@Service\r\n@RocketMQMessageListener(topic = \"${spring.rocketmq.topic}\", consumerGroup = \"string_consumer\")\r\nclass StringConsumer implements RocketMQListener<String> {\r\n    @Override\r\n    public void onMessage(String message) {\r\n        log.info(\"------- StringConsumer received: {}\", message);\r\n    }\r\n}","created_at":"2018-08-21T05:33:09Z","updated_at":"2018-08-21T05:33:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102/commits","review_comments_url":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102/comments","review_comment_url":"https://api.github.com/repos/apache/rocketmq-externals/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/rocketmq-externals/issues/102/comments","statuses_url":"https://api.github.com/repos/apache/rocketmq-externals/statuses/49263d27ad386d108d8e305dfcad57d67e2297ad","head":{"label":"walking98:master","ref":"master","sha":"49263d27ad386d108d8e305dfcad57d67e2297ad","user":{"login":"walking98","id":19318111,"node_id":"MDQ6VXNlcjE5MzE4MTEx","avatar_url":"https://avatars2.githubusercontent.com/u/19318111?v=4","gravatar_id":"","url":"https://api.github.com/users/walking98","html_url":"https://github.com/walking98","followers_url":"https://api.github.com/users/walking98/followers","following_url":"https://api.github.com/users/walking98/following{/other_user}","gists_url":"https://api.github.com/users/walking98/gists{/gist_id}","starred_url":"https://api.github.com/users/walking98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walking98/subscriptions","organizations_url":"https://api.github.com/users/walking98/orgs","repos_url":"https://api.github.com/users/walking98/repos","events_url":"https://api.github.com/users/walking98/events{/privacy}","received_events_url":"https://api.github.com/users/walking98/received_events","type":"User","site_admin":false},"repo":{"id":144250524,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQyNTA1MjQ=","name":"rocketmq-externals","full_name":"walking98/rocketmq-externals","owner":{"login":"walking98","id":19318111,"node_id":"MDQ6VXNlcjE5MzE4MTEx","avatar_url":"https://avatars2.githubusercontent.com/u/19318111?v=4","gravatar_id":"","url":"https://api.github.com/users/walking98","html_url":"https://github.com/walking98","followers_url":"https://api.github.com/users/walking98/followers","following_url":"https://api.github.com/users/walking98/following{/other_user}","gists_url":"https://api.github.com/users/walking98/gists{/gist_id}","starred_url":"https://api.github.com/users/walking98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/walking98/subscriptions","organizations_url":"https://api.github.com/users/walking98/orgs","repos_url":"https://api.github.com/users/walking98/repos","events_url":"https://api.github.com/users/walking98/events{/privacy}","received_events_url":"https://api.github.com/users/walking98/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/walking98/rocketmq-externals","description":"Mirror of Apache RocketMQ (Incubating)","fork":true,"url":"https://api.github.com/repos/walking98/rocketmq-externals","forks_url":"https://api.github.com/repos/walking98/rocketmq-externals/forks","keys_url":"https://api.github.com/repos/walking98/rocketmq-externals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/walking98/rocketmq-externals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/walking98/rocketmq-externals/teams","hooks_url":"https://api.github.com/repos/walking98/rocketmq-externals/hooks","issue_events_url":"https://api.github.com/repos/walking98/rocketmq-externals/issues/events{/number}","events_url":"https://api.github.com/repos/walking98/rocketmq-externals/events","assignees_url":"https://api.github.com/repos/walking98/rocketmq-externals/assignees{/user}","branches_url":"https://api.github.com/repos/walking98/rocketmq-externals/branches{/branch}","tags_url":"https://api.github.com/repos/walking98/rocketmq-externals/tags","blobs_url":"https://api.github.com/repos/walking98/rocketmq-externals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/walking98/rocketmq-externals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/walking98/rocketmq-externals/git/refs{/sha}","trees_url":"https://api.github.com/repos/walking98/rocketmq-externals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/walking98/rocketmq-externals/statuses/{sha}","languages_url":"https://api.github.com/repos/walking98/rocketmq-externals/languages","stargazers_url":"https://api.github.com/repos/walking98/rocketmq-externals/stargazers","contributors_url":"https://api.github.com/repos/walking98/rocketmq-externals/contributors","subscribers_url":"https://api.github.com/repos/walking98/rocketmq-externals/subscribers","subscription_url":"https://api.github.com/repos/walking98/rocketmq-externals/subscription","commits_url":"https://api.github.com/repos/walking98/rocketmq-externals/commits{/sha}","git_commits_url":"https://api.github.com/repos/walking98/rocketmq-externals/git/commits{/sha}","comments_url":"https://api.github.com/repos/walking98/rocketmq-externals/comments{/number}","issue_comment_url":"https://api.github.com/repos/walking98/rocketmq-externals/issues/comments{/number}","contents_url":"https://api.github.com/repos/walking98/rocketmq-externals/contents/{+path}","compare_url":"https://api.github.com/repos/walking98/rocketmq-externals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/walking98/rocketmq-externals/merges","archive_url":"https://api.github.com/repos/walking98/rocketmq-externals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/walking98/rocketmq-externals/downloads","issues_url":"https://api.github.com/repos/walking98/rocketmq-externals/issues{/number}","pulls_url":"https://api.github.com/repos/walking98/rocketmq-externals/pulls{/number}","milestones_url":"https://api.github.com/repos/walking98/rocketmq-externals/milestones{/number}","notifications_url":"https://api.github.com/repos/walking98/rocketmq-externals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/walking98/rocketmq-externals/labels{/name}","releases_url":"https://api.github.com/repos/walking98/rocketmq-externals/releases{/id}","deployments_url":"https://api.github.com/repos/walking98/rocketmq-externals/deployments","created_at":"2018-08-10T07:11:24Z","updated_at":"2018-08-21T05:17:50Z","pushed_at":"2018-08-21T05:17:48Z","git_url":"git://github.com/walking98/rocketmq-externals.git","ssh_url":"git@github.com:walking98/rocketmq-externals.git","clone_url":"https://github.com/walking98/rocketmq-externals.git","svn_url":"https://github.com/walking98/rocketmq-externals","homepage":null,"size":11902,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"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":"apache:master","ref":"master","sha":"f85f3c32760e116fa815a5f9663b48d29125cd83","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":84916374,"node_id":"MDEwOlJlcG9zaXRvcnk4NDkxNjM3NA==","name":"rocketmq-externals","full_name":"apache/rocketmq-externals","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/rocketmq-externals","description":"Mirror of Apache RocketMQ (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/rocketmq-externals","forks_url":"https://api.github.com/repos/apache/rocketmq-externals/forks","keys_url":"https://api.github.com/repos/apache/rocketmq-externals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/rocketmq-externals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/rocketmq-externals/teams","hooks_url":"https://api.github.com/repos/apache/rocketmq-externals/hooks","issue_events_url":"https://api.github.com/repos/apache/rocketmq-externals/issues/events{/number}","events_url":"https://api.github.com/repos/apache/rocketmq-externals/events","assignees_url":"https://api.github.com/repos/apache/rocketmq-externals/assignees{/user}","branches_url":"https://api.github.com/repos/apache/rocketmq-externals/branches{/branch}","tags_url":"https://api.github.com/repos/apache/rocketmq-externals/tags","blobs_url":"https://api.github.com/repos/apache/rocketmq-externals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/rocketmq-externals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/rocketmq-externals/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/rocketmq-externals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/rocketmq-externals/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/rocketmq-externals/languages","stargazers_url":"https://api.github.com/repos/apache/rocketmq-externals/stargazers","contributors_url":"https://api.github.com/repos/apache/rocketmq-externals/contributors","subscribers_url":"https://api.github.com/repos/apache/rocketmq-externals/subscribers","subscription_url":"https://api.github.com/repos/apache/rocketmq-externals/subscription","commits_url":"https://api.github.com/repos/apache/rocketmq-externals/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/rocketmq-externals/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/rocketmq-externals/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/rocketmq-externals/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/rocketmq-externals/contents/{+path}","compare_url":"https://api.github.com/repos/apache/rocketmq-externals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/rocketmq-externals/merges","archive_url":"https://api.github.com/repos/apache/rocketmq-externals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/rocketmq-externals/downloads","issues_url":"https://api.github.com/repos/apache/rocketmq-externals/issues{/number}","pulls_url":"https://api.github.com/repos/apache/rocketmq-externals/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/rocketmq-externals/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/rocketmq-externals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/rocketmq-externals/labels{/name}","releases_url":"https://api.github.com/repos/apache/rocketmq-externals/releases{/id}","deployments_url":"https://api.github.com/repos/apache/rocketmq-externals/deployments","created_at":"2017-03-14T07:00:06Z","updated_at":"2018-08-20T14:41:17Z","pushed_at":"2018-08-20T03:28:00Z","git_url":"git://github.com/apache/rocketmq-externals.git","ssh_url":"git@github.com:apache/rocketmq-externals.git","clone_url":"https://github.com/apache/rocketmq-externals.git","svn_url":"https://github.com/apache/rocketmq-externals","homepage":null,"size":11902,"stargazers_count":807,"watchers_count":807,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":596,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":596,"open_issues":7,"watchers":807,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102"},"html":{"href":"https://github.com/apache/rocketmq-externals/pull/102"},"issue":{"href":"https://api.github.com/repos/apache/rocketmq-externals/issues/102"},"comments":{"href":"https://api.github.com/repos/apache/rocketmq-externals/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/rocketmq-externals/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/rocketmq-externals/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/apache/rocketmq-externals/statuses/49263d27ad386d108d8e305dfcad57d67e2297ad"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":205,"deletions":7,"changed_files":5}}
{"actor":{"display_login":"walking98"}}