{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/siddhi/pulls/comments/110603346","pull_request_review_id":31783657,"id":110603346,"diff_hunk":"@@ -0,0 +1,192 @@\n+/*\n+ *  Copyright (c) 2017 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ *  WSO2 Inc. licenses this file to you under the Apache License,\n+ *  Version 2.0 (the \"License\"); you may not use this file except\n+ *  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,\n+ *  software distributed under the License is distributed on an\n+ *  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *  KIND, either express or implied.  See the License for the\n+ *  specific language governing permissions and limitations\n+ *  under the License.\n+ *\n+ */\n+package org.wso2.siddhi.extension.input.transport.jms.util;\n+\n+import org.apache.log4j.Logger;\n+\n+import javax.jms.Connection;\n+import javax.jms.ConnectionFactory;\n+import javax.jms.JMSException;\n+import javax.naming.InitialContext;\n+import javax.naming.NamingException;\n+import java.util.Hashtable;\n+\n+/**\n+ * The revamped JMS Transport listener implementation. Creates {@link JMSTaskManager} instances\n+ * for each service requesting exposure over JMS, and stops these if they are undeployed / stopped.\n+ * <p/>\n+ * A service indicates a JMS Connection factory definition by name, which would be defined in the\n+ * JMSListner on the axis2.xml, and this provides a way to reuse common configuration between\n+ * services, as well as to optimize resources utilized\n+ * <p/>\n+ * If the connection factory name was not specified, it will default to the one named \"default\"\n+ * {@see JMSConstants.DEFAULT_CONFAC_NAME}\n+ * <p/>\n+ * If a destination JNDI name is not specified, a service will expect to use a Queue with the same\n+ * JNDI name as of the service. Additional Parameters allows one to bind to a Topic or specify\n+ * many more detailed control options. See package documentation for more details\n+ * <p/>\n+ * All Destinations / JMS Administered objects used MUST be pre-created or already available\n+ */\n+public class JMSListener implements Runnable {\n+\n+    private static final Logger log = Logger.getLogger(JMSListener.class);\n+    private final String listenerName;\n+    private final JMSTaskManager jmsTaskManager;\n+\n+    public JMSListener(String listenerName, JMSTaskManager jmsTaskManager) {\n+        this.listenerName = listenerName;\n+        this.jmsTaskManager = jmsTaskManager;\n+    }\n+\n+\n+    /**\n+     * Listen for JMS messages on behalf of the given service\n+     */\n+    private void start() {\n+\n+        JMSTaskManager stm = jmsTaskManager;\n+        boolean connected = false;\n+\n+        /* The following parameters are used when trying to connect with the JMS provider at the start up*/\n+        int r = 1;\n+        long retryDuration = 10000;\n+        double reconnectionProgressionFactor = 2.0;\n+        long maxReconnectDuration = 1000 * 60 * 60; // 1 hour\n+\n+\n+        // First we will check whether jms provider is started or not, as if not it will throw a continuous error log\n+        // If jms provider not started we will wait for exponentially increasing time intervals,\n+        // till the provider is started\n+        while (!connected) {\n+            boolean jmsProviderStarted = checkJMSConnection(stm);\n+            if (jmsProviderStarted) {\n+                log.info(\"Connection attempt: \" + r + \" for JMS Provider for listener: \" + listenerName\n+                        + \" was successful!\");\n+                connected = true;\n+                stm.start();\n+\n+                for (int i = 0; i < 3; i++) {\n+                    // Check the consumer count rather than the active task count. Reason: if the\n+                    // destination is of type topic, then the transport is only ready to receive\n+                    // messages if at least one consumer exists. This is of not much importance,\n+                    // except for automated tests.\n+                    if (stm.getConsumerCount() > 0) {\n+                        log.info(\"Started to listen on destination : \" + stm.getDestinationJNDIName() +\n+                                \" of type \" + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) +\n+                                \" for listener \" + listenerName);\n+                        return;\n+                    }\n+                    try {\n+                        Thread.sleep(1000);\n+                    } catch (InterruptedException ignore) {\n+                    }\n+                }\n+\n+                log.warn(\"Polling tasks on destination : \" + stm.getDestinationJNDIName() +\n+                        \" of type \" + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) +\n+                        \" for listener \" + listenerName + \" have not yet started after 3 seconds ..\");\n+            } else {\n+                log.error(\"Unable to continue server startup as it seems the JMS Provider \" +\n+                        \"is not yet started. Please start the JMS provider now.\");\n+                retryDuration = (long) (retryDuration * reconnectionProgressionFactor);\n+                log.error(\"Connection attempt : \" + (r++) + \" for JMS Provider failed. Next retry in \"","path":"modules/siddhi-extensions/input-transports/jms-input-transport/src/main/java/org/wso2/siddhi/extension/input/transport/jms/util/JMSListener.java","position":109,"original_position":109,"commit_id":"780616fc593f36ce67b009542f18b9d497bc1c11","original_commit_id":"780616fc593f36ce67b009542f18b9d497bc1c11","user":{"login":"nirmal070125","id":413016,"avatar_url":"https://avatars3.githubusercontent.com/u/413016?v=3","gravatar_id":"","url":"https://api.github.com/users/nirmal070125","html_url":"https://github.com/nirmal070125","followers_url":"https://api.github.com/users/nirmal070125/followers","following_url":"https://api.github.com/users/nirmal070125/following{/other_user}","gists_url":"https://api.github.com/users/nirmal070125/gists{/gist_id}","starred_url":"https://api.github.com/users/nirmal070125/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nirmal070125/subscriptions","organizations_url":"https://api.github.com/users/nirmal070125/orgs","repos_url":"https://api.github.com/users/nirmal070125/repos","events_url":"https://api.github.com/users/nirmal070125/events{/privacy}","received_events_url":"https://api.github.com/users/nirmal070125/received_events","type":"User","site_admin":false},"body":"use String.format instead of concatenation. ","created_at":"2017-04-10T08:55:37Z","updated_at":"2017-04-10T08:59:02Z","html_url":"https://github.com/wso2/siddhi/pull/309#discussion_r110603346","pull_request_url":"https://api.github.com/repos/wso2/siddhi/pulls/309","_links":{"self":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/comments/110603346"},"html":{"href":"https://github.com/wso2/siddhi/pull/309#discussion_r110603346"},"pull_request":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/309"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/siddhi/pulls/309","id":115044527,"html_url":"https://github.com/wso2/siddhi/pull/309","diff_url":"https://github.com/wso2/siddhi/pull/309.diff","patch_url":"https://github.com/wso2/siddhi/pull/309.patch","issue_url":"https://api.github.com/repos/wso2/siddhi/issues/309","number":309,"state":"open","locked":false,"title":"Jms input transport with the test","user":{"login":"swsachith","id":1327121,"avatar_url":"https://avatars3.githubusercontent.com/u/1327121?v=3","gravatar_id":"","url":"https://api.github.com/users/swsachith","html_url":"https://github.com/swsachith","followers_url":"https://api.github.com/users/swsachith/followers","following_url":"https://api.github.com/users/swsachith/following{/other_user}","gists_url":"https://api.github.com/users/swsachith/gists{/gist_id}","starred_url":"https://api.github.com/users/swsachith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swsachith/subscriptions","organizations_url":"https://api.github.com/users/swsachith/orgs","repos_url":"https://api.github.com/users/swsachith/repos","events_url":"https://api.github.com/users/swsachith/events{/privacy}","received_events_url":"https://api.github.com/users/swsachith/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-04-10T08:00:25Z","updated_at":"2017-04-10T08:59:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72c05d1ee5ed069f47d0443575064627a4fa7aae","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/siddhi/pulls/309/commits","review_comments_url":"https://api.github.com/repos/wso2/siddhi/pulls/309/comments","review_comment_url":"https://api.github.com/repos/wso2/siddhi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/siddhi/issues/309/comments","statuses_url":"https://api.github.com/repos/wso2/siddhi/statuses/780616fc593f36ce67b009542f18b9d497bc1c11","head":{"label":"swsachith:jms-input-transport","ref":"jms-input-transport","sha":"780616fc593f36ce67b009542f18b9d497bc1c11","user":{"login":"swsachith","id":1327121,"avatar_url":"https://avatars3.githubusercontent.com/u/1327121?v=3","gravatar_id":"","url":"https://api.github.com/users/swsachith","html_url":"https://github.com/swsachith","followers_url":"https://api.github.com/users/swsachith/followers","following_url":"https://api.github.com/users/swsachith/following{/other_user}","gists_url":"https://api.github.com/users/swsachith/gists{/gist_id}","starred_url":"https://api.github.com/users/swsachith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swsachith/subscriptions","organizations_url":"https://api.github.com/users/swsachith/orgs","repos_url":"https://api.github.com/users/swsachith/repos","events_url":"https://api.github.com/users/swsachith/events{/privacy}","received_events_url":"https://api.github.com/users/swsachith/received_events","type":"User","site_admin":false},"repo":{"id":84922322,"name":"siddhi","full_name":"swsachith/siddhi","owner":{"login":"swsachith","id":1327121,"avatar_url":"https://avatars3.githubusercontent.com/u/1327121?v=3","gravatar_id":"","url":"https://api.github.com/users/swsachith","html_url":"https://github.com/swsachith","followers_url":"https://api.github.com/users/swsachith/followers","following_url":"https://api.github.com/users/swsachith/following{/other_user}","gists_url":"https://api.github.com/users/swsachith/gists{/gist_id}","starred_url":"https://api.github.com/users/swsachith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swsachith/subscriptions","organizations_url":"https://api.github.com/users/swsachith/orgs","repos_url":"https://api.github.com/users/swsachith/repos","events_url":"https://api.github.com/users/swsachith/events{/privacy}","received_events_url":"https://api.github.com/users/swsachith/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/swsachith/siddhi","description":null,"fork":true,"url":"https://api.github.com/repos/swsachith/siddhi","forks_url":"https://api.github.com/repos/swsachith/siddhi/forks","keys_url":"https://api.github.com/repos/swsachith/siddhi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swsachith/siddhi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swsachith/siddhi/teams","hooks_url":"https://api.github.com/repos/swsachith/siddhi/hooks","issue_events_url":"https://api.github.com/repos/swsachith/siddhi/issues/events{/number}","events_url":"https://api.github.com/repos/swsachith/siddhi/events","assignees_url":"https://api.github.com/repos/swsachith/siddhi/assignees{/user}","branches_url":"https://api.github.com/repos/swsachith/siddhi/branches{/branch}","tags_url":"https://api.github.com/repos/swsachith/siddhi/tags","blobs_url":"https://api.github.com/repos/swsachith/siddhi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swsachith/siddhi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swsachith/siddhi/git/refs{/sha}","trees_url":"https://api.github.com/repos/swsachith/siddhi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swsachith/siddhi/statuses/{sha}","languages_url":"https://api.github.com/repos/swsachith/siddhi/languages","stargazers_url":"https://api.github.com/repos/swsachith/siddhi/stargazers","contributors_url":"https://api.github.com/repos/swsachith/siddhi/contributors","subscribers_url":"https://api.github.com/repos/swsachith/siddhi/subscribers","subscription_url":"https://api.github.com/repos/swsachith/siddhi/subscription","commits_url":"https://api.github.com/repos/swsachith/siddhi/commits{/sha}","git_commits_url":"https://api.github.com/repos/swsachith/siddhi/git/commits{/sha}","comments_url":"https://api.github.com/repos/swsachith/siddhi/comments{/number}","issue_comment_url":"https://api.github.com/repos/swsachith/siddhi/issues/comments{/number}","contents_url":"https://api.github.com/repos/swsachith/siddhi/contents/{+path}","compare_url":"https://api.github.com/repos/swsachith/siddhi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swsachith/siddhi/merges","archive_url":"https://api.github.com/repos/swsachith/siddhi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swsachith/siddhi/downloads","issues_url":"https://api.github.com/repos/swsachith/siddhi/issues{/number}","pulls_url":"https://api.github.com/repos/swsachith/siddhi/pulls{/number}","milestones_url":"https://api.github.com/repos/swsachith/siddhi/milestones{/number}","notifications_url":"https://api.github.com/repos/swsachith/siddhi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swsachith/siddhi/labels{/name}","releases_url":"https://api.github.com/repos/swsachith/siddhi/releases{/id}","deployments_url":"https://api.github.com/repos/swsachith/siddhi/deployments","created_at":"2017-03-14T08:07:07Z","updated_at":"2017-03-14T08:07:10Z","pushed_at":"2017-04-10T08:06:31Z","git_url":"git://github.com/swsachith/siddhi.git","ssh_url":"git@github.com:swsachith/siddhi.git","clone_url":"https://github.com/swsachith/siddhi.git","svn_url":"https://github.com/swsachith/siddhi","homepage":null,"size":7508,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"b480b66ff749d2eed03f8af0b44e12852682e3ae","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars0.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":18988631,"name":"siddhi","full_name":"wso2/siddhi","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars0.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/siddhi","description":null,"fork":false,"url":"https://api.github.com/repos/wso2/siddhi","forks_url":"https://api.github.com/repos/wso2/siddhi/forks","keys_url":"https://api.github.com/repos/wso2/siddhi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/siddhi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/siddhi/teams","hooks_url":"https://api.github.com/repos/wso2/siddhi/hooks","issue_events_url":"https://api.github.com/repos/wso2/siddhi/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/siddhi/events","assignees_url":"https://api.github.com/repos/wso2/siddhi/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/siddhi/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/siddhi/tags","blobs_url":"https://api.github.com/repos/wso2/siddhi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/siddhi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/siddhi/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/siddhi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/siddhi/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/siddhi/languages","stargazers_url":"https://api.github.com/repos/wso2/siddhi/stargazers","contributors_url":"https://api.github.com/repos/wso2/siddhi/contributors","subscribers_url":"https://api.github.com/repos/wso2/siddhi/subscribers","subscription_url":"https://api.github.com/repos/wso2/siddhi/subscription","commits_url":"https://api.github.com/repos/wso2/siddhi/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/siddhi/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/siddhi/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/siddhi/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/siddhi/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/siddhi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/siddhi/merges","archive_url":"https://api.github.com/repos/wso2/siddhi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/siddhi/downloads","issues_url":"https://api.github.com/repos/wso2/siddhi/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/siddhi/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/siddhi/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/siddhi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/siddhi/labels{/name}","releases_url":"https://api.github.com/repos/wso2/siddhi/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/siddhi/deployments","created_at":"2014-04-21T09:51:36Z","updated_at":"2017-03-31T13:32:06Z","pushed_at":"2017-04-10T08:06:32Z","git_url":"git://github.com/wso2/siddhi.git","ssh_url":"git@github.com:wso2/siddhi.git","clone_url":"https://github.com/wso2/siddhi.git","svn_url":"https://github.com/wso2/siddhi","homepage":null,"size":7462,"stargazers_count":241,"watchers_count":241,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":196,"mirror_url":null,"open_issues_count":18,"forks":196,"open_issues":18,"watchers":241,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/309"},"html":{"href":"https://github.com/wso2/siddhi/pull/309"},"issue":{"href":"https://api.github.com/repos/wso2/siddhi/issues/309"},"comments":{"href":"https://api.github.com/repos/wso2/siddhi/issues/309/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/309/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/siddhi/pulls/309/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/siddhi/statuses/780616fc593f36ce67b009542f18b9d497bc1c11"}}}}
{"actor":{"display_login":"nirmal070125"}}