git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Count of number errors during split processed for reporting


Fairly new to Camel, and am using it under springboot.

I am attempting to get a Running Failure Count to report it after my route has completed…  Code is below.
However I am having some sort of scope issue, or something, in my processor where I increment and log out the failCount variable, it properly increments and shows up in the log as 1 higher number for every error caught…

However, any attempt to use the DSL .log.. such as .log(“FAILED COUNT :”+failCount), always Displays 0 for Failcount.

IE, when the onException executes for the first time the log will show:

FAILURECOUNT: 1
FAILURECOUNT 1: 0

On the secont failure handled:
FAILURECOUNT: 2
FAILURECOUNT 1: 0

and of course the final report in the onCompletion always shows

FAILURECOUNT 0

So I am rather confused what is going on…

I even tried to put the failurecount in a msg header, and this worked find for the onException, pulling the header and displaying it.. but the .log on the onCompletion, the header wasn’t passed through in its message.. So I am perplexed.. How do I do this?  I assume this should be pretty simple…


@Component
public class MyRoute extends RouteBuilder {

   int failCount;

    @Override
    public void configure() {

        onException(Exception.class)
                .maximumRedeliveries(0)
                .to("metrics:counter:OneContent Failure Count")

                .process(new Processor() {
                             public void process(Exchange exchange) {

                                 Do My Processing

                                 failCount++;
                                 LOG.info("FAILURECOUNT "+failCount);

                             }
                         }
                ) .log("FAILURECOUNT 1“+failCount);



        from( props.getProperty("sourceFile")+"?move=.done&moveFailed=.error").routeId("OneContent Route")
                                               .onCompletion().modeAfterConsumer()
.log(“FAILURE COUNT:”+failCount);
               .end()

                .to("bean:getShare")
                .unmarshal(csv)
                .split(body()).parallelProcessing(true)
                    .to("bean:MyProcessor").to("metrics:counter:OneContent records processed")

                .end()
                .log("failed count: failCount);



    }
}