Same question posted on Stackoverflow
http://stackoverflow.com/questions/30809200/how-to-identify-whether-all-nodes-are-processed

On Sat, Jun 13, 2015 at 2:36 PM, mnki <jobs.mohan...@gmail.com> wrote:
> I have created a interceptor added to the context.This interceptor is getting
> executed for each node in the route.But i want to identify when processing
> of all nodes is complete and do some action.
>
>  public class MyInterceptStrategy implements InterceptStrategy {
>
> public int count = 0;
>
> @Override
> public Processor wrapProcessorInInterceptors(final CamelContext context,
>         final ProcessorDefinition<?> definition, final Processor target,
>         final Processor nextTarget) throws Exception {
>     return new DelegateAsyncProcessor(new Processor() {
>
>         @Override
>         public void process(Exchange exchange) throws Exception {
>             count++;
>             target.process(exchange);
>             //if this is the last node print the message "all nodes
> processed" and count is "count"
>             //System.out.println(count);
>         }
>     }) {
>
>     };
>
> }
> }
>
> UPDATE:Tried doing this to get the total count of nodes,but this returns all
> the nodes in all the routes and not just the nodes that are eligible for
> processing.
>
> public int getTotalProcessors(CamelContext context) {
>     int totalProcessorsCount = 0;
>     for (Route r : context.getRoutes()) {
>         totalProcessorsCount = totalProcessorsCount +
> r.getRouteContext().getRoute().getOutputs().size();
>     }
>     return totalProcessorsCount;
> }
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-to-identify-whether-all-nodes-are-processed-tp5768169.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to