{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/comments/170077053","pull_request_review_id":98698982,"id":170077053,"diff_hunk":"@@ -0,0 +1,142 @@\n+= Polling Sources\n+*Available since version 1.1*\n+\n+Polling Sources are Sources that instead of being triggered by an external action, they poll\n+data items periodically depending on a `scheduling strategy` that determines the frequency at\n+which the poll happens. Every item is dispatched to the flow as a single `Message`.\n+\n+== How to create a Polling Source\n+\n+To create a Polling Source, first we will need to use add our Source class to the\n+`@Sources` annotation on our extension class, just like regular Sources. For a Source\n+to behave as a PollingSource, instead of extending the class `Source<T,A>`, it will have\n+to extend from `PollingSource<T, A>`.\n+\n+By extending from `PollingSource<T, A>` you will need to implement the methods `poll` and\n+`onRejectedItem`.\n+\n+- `pool` is responsible for obtaining the items to be dispatched and communicate them through the `pollContext`\n+using the `accept` method.\n+\n+- `onRejectedItem` will be called if one of the items dispatched was rejected (either by watermarking,\n+idempotency, server overload, etc.), this method will be called to released any resources associated to result set\n+to the `PollItem`\n+\n+Let's put as example a simplified version of the directory listener of FTP Connector:\n+\n+[source, java, linenums]\n+----\n+public class FtpDirectoryListener extends PollingSource<InputStream, FtpFileAttributes> {\n+  @Override\n+  public void poll(PollContext<InputStream, FtpFileAttributes> pollContext) {\n+    if (pollContext.isSourceStopping()) {\n+      return;\n+    }\n+    List<FtpFileAttributes> attributesList = listFiles().getAttributes();\n+\n+    for (FtpFileAttributes attributes : attributesList) {\n+      if(pollContext.isSourceStopping()){  // <1>\n+        break;\n+      }\n+      processFile(attributesList, pollContext)\n+    }\n+  }\n+\n+  @Override\n+  public void onRejectedItem(Result<InputStream, FtpFileAttributes> result, SourceCallbackContext callbackContext) {\n+    closeQuietly(result.getOutput());","path":"mule-sdk/v/1.1/polling-sources.adoc","position":47,"original_position":47,"commit_id":"e7b3bb40ef66926452aadc4331560d1f9389a702","original_commit_id":"a7a18861039dd3bcf22cf4901200cf3c62675f24","user":{"login":"alegmarra","id":1502904,"avatar_url":"https://avatars1.githubusercontent.com/u/1502904?v=4","gravatar_id":"","url":"https://api.github.com/users/alegmarra","html_url":"https://github.com/alegmarra","followers_url":"https://api.github.com/users/alegmarra/followers","following_url":"https://api.github.com/users/alegmarra/following{/other_user}","gists_url":"https://api.github.com/users/alegmarra/gists{/gist_id}","starred_url":"https://api.github.com/users/alegmarra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alegmarra/subscriptions","organizations_url":"https://api.github.com/users/alegmarra/orgs","repos_url":"https://api.github.com/users/alegmarra/repos","events_url":"https://api.github.com/users/alegmarra/events{/privacy}","received_events_url":"https://api.github.com/users/alegmarra/received_events","type":"User","site_admin":false},"body":"replace with a more abstract \"closeFileStream(result)\" or somehting like that. The idea has to be cleanup and resource release ","created_at":"2018-02-22T20:02:01Z","updated_at":"2018-02-22T20:19:05Z","html_url":"https://github.com/mulesoft/mulesoft-docs/pull/2266#discussion_r170077053","pull_request_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/comments/170077053"},"html":{"href":"https://github.com/mulesoft/mulesoft-docs/pull/2266#discussion_r170077053"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266","id":170798612,"html_url":"https://github.com/mulesoft/mulesoft-docs/pull/2266","diff_url":"https://github.com/mulesoft/mulesoft-docs/pull/2266.diff","patch_url":"https://github.com/mulesoft/mulesoft-docs/pull/2266.patch","issue_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/2266","number":2266,"state":"closed","locked":false,"title":"Adds polling sources documentation","user":{"login":"ndinu","id":13604295,"avatar_url":"https://avatars2.githubusercontent.com/u/13604295?v=4","gravatar_id":"","url":"https://api.github.com/users/ndinu","html_url":"https://github.com/ndinu","followers_url":"https://api.github.com/users/ndinu/followers","following_url":"https://api.github.com/users/ndinu/following{/other_user}","gists_url":"https://api.github.com/users/ndinu/gists{/gist_id}","starred_url":"https://api.github.com/users/ndinu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndinu/subscriptions","organizations_url":"https://api.github.com/users/ndinu/orgs","repos_url":"https://api.github.com/users/ndinu/repos","events_url":"https://api.github.com/users/ndinu/events{/privacy}","received_events_url":"https://api.github.com/users/ndinu/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-22T16:25:00Z","updated_at":"2018-02-22T20:19:05Z","closed_at":"2018-02-22T19:44:15Z","merged_at":"2018-02-22T19:44:15Z","merge_commit_sha":"e30ac497b4fe04571dc1a888e47beafd4e06a0ac","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/2266/comments","statuses_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/statuses/e7b3bb40ef66926452aadc4331560d1f9389a702","head":{"label":"mulesoft:polling-sources-","ref":"polling-sources-","sha":"e7b3bb40ef66926452aadc4331560d1f9389a702","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars1.githubusercontent.com/u/185740?v=4","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":35906390,"name":"mulesoft-docs","full_name":"mulesoft/mulesoft-docs","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars1.githubusercontent.com/u/185740?v=4","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mulesoft-docs","description":"Main MuleSoft documentation repository","fork":false,"url":"https://api.github.com/repos/mulesoft/mulesoft-docs","forks_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/forks","keys_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/teams","hooks_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/events","assignees_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/tags","blobs_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/subscription","commits_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/merges","archive_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/downloads","issues_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/deployments","created_at":"2015-05-19T20:21:17Z","updated_at":"2018-02-19T20:25:50Z","pushed_at":"2018-02-22T20:18:23Z","git_url":"git://github.com/mulesoft/mulesoft-docs.git","ssh_url":"git@github.com:mulesoft/mulesoft-docs.git","clone_url":"https://github.com/mulesoft/mulesoft-docs.git","svn_url":"https://github.com/mulesoft/mulesoft-docs","homepage":null,"size":923925,"stargazers_count":81,"watchers_count":81,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":380,"mirror_url":null,"archived":false,"open_issues_count":45,"license":null,"forks":380,"open_issues":45,"watchers":81,"default_branch":"master"}},"base":{"label":"mulesoft:beta-anypt","ref":"beta-anypt","sha":"7cd02faba963f43105f396a6bdee423d80229643","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars1.githubusercontent.com/u/185740?v=4","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":35906390,"name":"mulesoft-docs","full_name":"mulesoft/mulesoft-docs","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars1.githubusercontent.com/u/185740?v=4","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mulesoft-docs","description":"Main MuleSoft documentation repository","fork":false,"url":"https://api.github.com/repos/mulesoft/mulesoft-docs","forks_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/forks","keys_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/teams","hooks_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/events","assignees_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/tags","blobs_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/subscription","commits_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/merges","archive_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/downloads","issues_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mulesoft-docs/deployments","created_at":"2015-05-19T20:21:17Z","updated_at":"2018-02-19T20:25:50Z","pushed_at":"2018-02-22T20:18:23Z","git_url":"git://github.com/mulesoft/mulesoft-docs.git","ssh_url":"git@github.com:mulesoft/mulesoft-docs.git","clone_url":"https://github.com/mulesoft/mulesoft-docs.git","svn_url":"https://github.com/mulesoft/mulesoft-docs","homepage":null,"size":923925,"stargazers_count":81,"watchers_count":81,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":380,"mirror_url":null,"archived":false,"open_issues_count":45,"license":null,"forks":380,"open_issues":45,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266"},"html":{"href":"https://github.com/mulesoft/mulesoft-docs/pull/2266"},"issue":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/2266"},"comments":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/issues/2266/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/pulls/2266/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mulesoft-docs/statuses/e7b3bb40ef66926452aadc4331560d1f9389a702"}},"author_association":"NONE"}}
{"actor":{"display_login":"alegmarra"}}