I am configuring Kafka as a source in my RouteBuilder. My goal is to handle Kafka disconnection issues. My RouteBuilder is as follows: new RouteBuilder() { public void configure() { onException(Exception.class).process(exchange -> { final Exception exception = exchange.getException(); logger.error(exception.getMessage()); // will do more processing here }); from(String.format("kafka:%s?brokers=%s:%s", topicName, host, port)).bean(getMyService(), "myMethod") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // some more processing } }); } };
I am configuring Kafka as a source in my RouteBuilder. My goal is to handle Kafka disconnection issues. My RouteBuilder is as follows: new RouteBuilder() { public void configure() { onException(Exception.class).process(exchange -> { final Exception exception = exchange.getException(); logger.error(exception.getMessage()); // will do more processing here }); from(String.format("kafka:%s?brokers=%s:%s", topicName, host, port)).bean(getMyService(), "myMethod") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // some more processing } }); } }; I provided wrong host and port, and expected to see an exception. However, no exception is seen in the log, and the onException processing is not get called. Any idea what I am doing wrong? A similar problem can be reproduced by running https://github.com/apache/camel/blob/master/examples/camel-example-kafka/src/main/java/org/apache/camel/example/kafka/MessageConsumerClient.java locally without any Kafka server running. Doing so results in a constant flow of messages: Connection to node -1 could not be established. Broker may not be available. Is there a way to have an exception thrown? Any help would be appreciated. YACOV SCHONDORF Sr. Software Engineer FORCEPOINT ph: +972.9.776.4233 fax: www.forcepoint.com<http://www.forcepoint.com> FORWARD WITHOUT FEAR