debugging - Apache camel bindy - how to log or debug -
i'm trying log informations camel bindy. had working setup using bindycsvdataformat bindyproduct annotated product-bean , csv file source.
now changed csv file , annotated bean. processing seams stuck within bindy processor, not informations/logs. debugprocessor not reached @ all. if set before unmarshal step, logs stuff , can debug it. wonder why new files not fit / match more , why there no logs or exceptions or whatever of help.
from("file:csv-testdata") .unmarshal(bindyproduct) .process(debugprocessor)
thanks in advance aj
logging of exceptions in apache camel
when asked question, @ origin of camel riding experience. in meantime found out great ways to achieve, looking for. if else searching reply question:
1. first approach: enable logging project, configure , and process logging adding logging urls route.1.1 add together dependencies logging pom.xml e.g
<groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>1.7.5</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>1.7.5</version> </dependency>
1.2 add together log4j.properties file src/main/resources folder (if want utilize log4j). define loglevel, appenders etc. there
1.3 add together logging route
from("...") .unmarshal(bindyproduct) .to("log:com.your.package.yourchosenname?level=error&multiline=true&showcaughtexception=true") .to(...);
a list of options can found here http://camel.apache.org/log.html can utilize
&showall=true
to log informations headers, properties, body etc
keep in mind, severity of loglevel of urls "level=" alternative must equal or higher one, defined in log4j.properties file
2. sec approach define debugprocessor logs exception , set in route right after processor, behaves mysteriously2.1 write debugprocessor processor has implement public void process(exchange exchange) throws exception {
if wondering why can't find exception in
exchange.getexception()
try retrieving using
exception exception = (exception) exchange.getproperty(exchange.exception_caught);
do ever exception (log sysout, ...)
2.2 wire debugger route within routebuilder java-class (or elsewhere, spring, xml, ...)
debugprocessor debugprocessor1 = new debugprocessor(); from("...") .unmarshal(bindyproduct) .process(debugprocessor1) .to(...);
3. 3rd approach use camels .dotry()/.docatch() or (maybe better) utilize onexception() route (http://camel.apache.org/exception-clause.html / camel.apache.org/try-catch-finally.html)
3.1 build onexception() route separated route want debug
the next onexception route aggregates exceptions , writes them downwards nice, human readable way (via velocity template) , every 5 seconds or 10 exeptions:
onexception(exception.class) // or special excepion (io, etc) .aggregate(header("camelfileparent"), new exceptionaggregationstrategy()) .completionsize(10).completiontimeout(5000) .to("velocity:velocity/errors.log.vm") .to("file:camel/xml-out?filename=errors-${file:name.noext}-${date:now:yyyy-mm-dd_hh-mm-ss-sss}.log");
this example, can ever want , camel able to, e.g. send them mail, set them in db etc.
you don't need processors or logging stuff in route now:
from("...") .unmarshal(bindyproduct) .to(...);
debugging logging apache-camel eip bindy
No comments:
Post a Comment