{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/1737","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/1737/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/1737/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/1737/events","html_url":"https://github.com/spring-cloud/spring-cloud-stream/issues/1737","id":457982389,"node_id":"MDU6SXNzdWU0NTc5ODIzODk=","number":1737,"title":"@StreamListener(\"errorChannel\") not working","user":{"login":"mjmunizsa","id":44818608,"node_id":"MDQ6VXNlcjQ0ODE4NjA4","avatar_url":"https://avatars0.githubusercontent.com/u/44818608?v=4","gravatar_id":"","url":"https://api.github.com/users/mjmunizsa","html_url":"https://github.com/mjmunizsa","followers_url":"https://api.github.com/users/mjmunizsa/followers","following_url":"https://api.github.com/users/mjmunizsa/following{/other_user}","gists_url":"https://api.github.com/users/mjmunizsa/gists{/gist_id}","starred_url":"https://api.github.com/users/mjmunizsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjmunizsa/subscriptions","organizations_url":"https://api.github.com/users/mjmunizsa/orgs","repos_url":"https://api.github.com/users/mjmunizsa/repos","events_url":"https://api.github.com/users/mjmunizsa/events{/privacy}","received_events_url":"https://api.github.com/users/mjmunizsa/received_events","type":"User","site_admin":false},"labels":[{"id":813808614,"node_id":"MDU6TGFiZWw4MTM4MDg2MTQ=","url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/labels/waiting-on-feedback","name":"waiting-on-feedback","color":"5dff3d","default":false}],"state":"open","locked":false,"assignee":{"login":"artembilan","id":1071590,"node_id":"MDQ6VXNlcjEwNzE1OTA=","avatar_url":"https://avatars3.githubusercontent.com/u/1071590?v=4","gravatar_id":"","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},"assignees":[{"login":"artembilan","id":1071590,"node_id":"MDQ6VXNlcjEwNzE1OTA=","avatar_url":"https://avatars3.githubusercontent.com/u/1071590?v=4","gravatar_id":"","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}],"milestone":null,"comments":3,"created_at":"2019-06-19T12:24:14Z","updated_at":"2019-06-19T15:12:49Z","closed_at":null,"author_association":"NONE","body":"I want to handle error with errorChannel subscriber for all channels.\r\n\r\nI'm using spring-cloud-stream-binder-aws-kinesis.\r\n\r\nI use a particular interface for EnableBinding (StreamProcessor.class):\r\n```\r\npublic interface StreamProcessor {\r\n\r\n\t@Input\r\n\tSubscribableChannel inputBar();\r\n\r\n\t@Input\r\n\tSubscribableChannel inputFoo();\r\n\r\n```\r\nI have implemented two StreamListeners:\r\n```\r\n@EnableBinding(StreamProcessor.class)\r\npublic class FooConsumer {\r\n\r\n\t@StreamListener(\"inputFoo\")\r\n\tpublic void inputFoo(Message<?> inputMessage) {\r\n              throw new RuntimeException(\"Boom\");\r\n        }\r\n}\r\n```\r\n```\r\n@EnableBinding(StreamProcessor.class)\r\npublic class BarConsumer {\r\n\r\n\t@StreamListener(\"inputBar\")\r\n\tpublic void inputBar(Message<?> inputMessage) {\r\n              throw new RuntimeException(\"Boom\");\r\n        }\r\n}\r\n```\r\nAnd  finally I have implemented a streamListener for the error channel for the two previous channels. \r\n```\r\n@EnableBinding(StreamProcessor.class)\r\npublic class StreamConsumerError{\r\n\r\n\t@StreamListener(\"errorChannel\")\r\n\tpublic void error(Message<?> message) {\r\n\t\tSystem.out.println(\"Handling ERROR: \" + message);\r\n\t}\r\n\r\n}\r\n```\r\nWhen I run the application it never goes through the Channel error and an exception is launched with the message:\r\n\r\n```\r\nConsider to use 'errorChannel' flow for the compensation logic.\r\norg.springframework.messaging.converter.MessageConversionException: Could not read JSON: Unrecognized token 'org': was expecting ('true', 'false' or 'null')\r\n```\r\n\r\nI have reviewed the application boot log and the Channel error subscriber is displayed:\r\n```\r\nChannel 'Events hub consumer-1.errorChannel' has 1 subscriber(s).\r\nChannel 'Events hub consumer-1.inputFoo' has 1 subscriber(s).\r\nChannel 'Events hub consumer-1.inputBar' has 1 subscriber(s).\r\n\r\n\r\nRegistering MessageChannel inputFoo\r\nRegistering MessageChannel inputBar\r\nRegistering MessageChannel errorChannel\r\n```\r\n\r\nThis error seems similar to the one reported in the issue: https://github.com/spring-cloud/spring-cloud-stream/issues/1618\r\n\r\nI am using kinesis instead of rabbit, specifically version 1.1.0. I have tried 1.2.0 and I also get the same error.\r\n\r\nSorry for my ignorance on this subject, but is that I'm starting with spring cloud stream.\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/comments/503603580","html_url":"https://github.com/spring-cloud/spring-cloud-stream/issues/1737#issuecomment-503603580","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-stream/issues/1737","id":503603580,"node_id":"MDEyOklzc3VlQ29tbWVudDUwMzYwMzU4MA==","user":{"login":"artembilan","id":1071590,"node_id":"MDQ6VXNlcjEwNzE1OTA=","avatar_url":"https://avatars3.githubusercontent.com/u/1071590?v=4","gravatar_id":"","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},"created_at":"2019-06-19T15:12:49Z","updated_at":"2019-06-19T15:12:49Z","author_association":"CONTRIBUTOR","body":"Well, sounds like you do have a send into the error channel:\r\n```\r\nat org.springframework.integration.endpoint.MessageProducerSupport.sendErrorMessageIfNecessary(MessageProducerSupport.java:224)\r\n```\r\nAnd that deserialization error is exactly about an attempt to deserialize an `Exception` object as a JSON:\r\n```\r\nCaused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'org': was expecting ('true', 'false' or 'null')\r\n at [Source: (String)\"org.springframework.messaging.MessagingException: Exception thrown while invoking com.melia.events.hub.consumer.service.consumer.FooConsumer#inputFoo[1 args]; nested exception is java.lang.RuntimeException: Boom, failedMessage=GenericMessage [payload=byte[3], headers={spanTraceId=46d364fb9468debd, spanId=46d364fb9468debd, nativeHeaders={spanTraceId=[46d364fb9468debd], spanId=[279c1eb2d3d0c46b], spanSampled=[1], spanParentSpanId=[641f56b3d374fd5c], X-B3-TraceId=[46d364fb9468debd], X-B3-SpanId=[27\"[truncated 461 chars]; line: 1, column: 4]\r\n\tat com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)\r\n\tat com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:703)\r\n\tat com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2853)\r\n\tat com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1899)\r\n\tat com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:757)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4141)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4000)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)\r\n\tat org.springframework.messaging.converter.MappingJackson2MessageConverter.convertFromInternal(MappingJackson2MessageConverter.java:229)\r\n```\r\n\r\nNot sure what is going on, but there is definitely something wrong in the:\r\n```\r\nat org.springframework.cloud.stream.config.SmartMessageMethodArgumentResolver.convertPayload(SmartMessageMethodArgumentResolver.java:110)\r\nat org.springframework.cloud.stream.config.SmartMessageMethodArgumentResolver.resolveArgument(SmartMessageMethodArgumentResolver.java:81)\r\n```\r\n\r\nI don't think the issue is related to Kinesis at all. Such a problem may simple has a place independently of the binder.\r\nAnyway, please, share a simple sample: I'm going to test it against `kinesalite`. I'm curious at what point an exception is converted into `toString()`, so the conversion fails meanwhile we really would like to have there an `ErrorMessage` as is."}}
{"actor":{"display_login":"artembilan"}}