camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Re: Camel: detect Kafka wrong IP
Date Thu, 16 Nov 2017 14:38:02 GMT
On Thu, Nov 16, 2017 at 3:33 PM, Schondorf, Yacov
<yschondorf@forcepoint.com> wrote:
> Hi,
>
> Thanks for your reply! I don't have the CIA2 book (would love to buy it though). Is there
an example online?
>

You can ask your employer to buy it - knowledge is cheap when you have
it all in a book.
The book has source code with a bunch of examples.

Also you can study to Camel error handling pages on the website.

> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Thursday, November 16, 2017 4:28 PM
> To: users@camel.apache.org
> Subject: EXTERNAL: Re: Camel: detect Kafka wrong IP
>
> Hi
>
> This is expected. onException in the route builder only happens when you have a Camel
exchange/message to route. And you dont have that because you cannot connect to Kafka.
>
> See for example the CiA2 book error handling chapter which talks about this, and how
some Camel components allow to bridge and report this as a Camel exchange with the exception
so you can deal with it using onException.
>
> On Thu, Nov 16, 2017 at 3:13 PM, Schondorf, Yacov <yschondorf@forcepoint.com> wrote:
>> 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
>>
>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Mime
View raw message