{"action":"created","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/21","labels_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/21/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/21/events","html_url":"https://github.com/vert-x3/vertx-rx/issues/21","id":110668166,"number":21,"title":"Exceptions within a subscriber stops a consumer","user":{"login":"johnoliver","id":1615532,"avatar_url":"https://avatars.githubusercontent.com/u/1615532?v=3","gravatar_id":"","url":"https://api.github.com/users/johnoliver","html_url":"https://github.com/johnoliver","followers_url":"https://api.github.com/users/johnoliver/followers","following_url":"https://api.github.com/users/johnoliver/following{/other_user}","gists_url":"https://api.github.com/users/johnoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/johnoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnoliver/subscriptions","organizations_url":"https://api.github.com/users/johnoliver/orgs","repos_url":"https://api.github.com/users/johnoliver/repos","events_url":"https://api.github.com/users/johnoliver/events{/privacy}","received_events_url":"https://api.github.com/users/johnoliver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-09T14:18:26Z","updated_at":"2015-10-12T10:48:02Z","closed_at":null,"body":"Following code demonstrates the problem. As can be seen if the subscriber throws an error the consumer is killed. This was unexpected for me as I expected consumers to remain subscribed even though a single invocation may throw an exception.\r\n\r\n\r\n```\r\n        new EventBus(eventBus)\r\n                .consumer(\"foo\")\r\n                .toObservable()\r\n                .subscribe(msg -> {\r\n                    System.out.println(\"Seen: \" + msg.body());\r\n                    if (msg.body().equals(2)) {\r\n                        throw new RuntimeException(\"error\");\r\n                    }\r\n                });\r\n\r\n        eventBus.send(\"foo\", 1);\r\n        eventBus.send(\"foo\", 2);\r\n        eventBus.send(\"foo\", 3);\r\n```"},"comment":{"url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/comments/147364251","html_url":"https://github.com/vert-x3/vertx-rx/issues/21#issuecomment-147364251","issue_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/21","id":147364251,"user":{"login":"johnoliver","id":1615532,"avatar_url":"https://avatars.githubusercontent.com/u/1615532?v=3","gravatar_id":"","url":"https://api.github.com/users/johnoliver","html_url":"https://github.com/johnoliver","followers_url":"https://api.github.com/users/johnoliver/followers","following_url":"https://api.github.com/users/johnoliver/following{/other_user}","gists_url":"https://api.github.com/users/johnoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/johnoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnoliver/subscriptions","organizations_url":"https://api.github.com/users/johnoliver/orgs","repos_url":"https://api.github.com/users/johnoliver/repos","events_url":"https://api.github.com/users/johnoliver/events{/privacy}","received_events_url":"https://api.github.com/users/johnoliver/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T10:48:02Z","updated_at":"2015-10-12T10:48:02Z","body":"This doesn’t really work since the only way to know that an error has occurred is to surround the subscribe block with a try catch block (note onError does not apply to errors in subscribers), and if you are doing that rather than resubscribing you may as well just not rethrow the exception. So as far as I can tell the only way to deal with this at the moment is to surround every subscriber to a .consumer with a try catch block, and if you forget it will become unreliable.\r\n\r\nYou will also need to catch exceptions on any function chained off of a consumer too, otherwise you would need to use onError to try to do the resubscription as mentioned.\r\n\r\nI am willing to bet other methods that are expected to be permanent such as periodic also suffer from this problem.\r\n\r\n"}}