[ 
https://issues.apache.org/jira/browse/CAMEL-19367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17723864#comment-17723864
 ] 

Claus Ibsen commented on CAMEL-19367:
-------------------------------------

You can do something like

public class MyNotifier extends org.apache.camel.support.EventNotifierSupport {

        public boolean isEnabled(CamelEvent event) {
                return event instanceof CamelEvent.ExchangeCompletedEvent || 
event instanceof CamelEvent.ExchangeFailedEvent;
    }

    @Override
    public void notify(CamelEvent event) throws Exception {
        int size = getCamelContext().getInflightRepository().size();
        System.out.println("exchange done and " + size + " inflights");
    }

}


Which gives me

2023-05-18 11:15:00.403  INFO 42495 --- [tifier_Worker-1] cron.yaml:16          
              : Parrot
exchange done and 1 inflights
2023-05-18 11:15:00.405  INFO 42495 --- [tifier_Worker-1] cron.yaml:16          
              : Cockatiel
exchange done and 1 inflights
2023-05-18 11:15:00.407  INFO 42495 --- [tifier_Worker-1] cron.yaml:16          
              : Pigeon
exchange done and 1 inflights
2023-05-18 11:15:00.408  INFO 42495 --- [tifier_Worker-1] cron.yaml:17          
              : [Parrot, Cockatiel, Pigeon]
2023-05-18 11:15:00.410  INFO 42495 --- [tifier_Worker-1] cron.yaml:18          
              : end
exchange done and 0 inflights

> CamelEvent.RouteCompleted
> -------------------------
>
>                 Key: CAMEL-19367
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19367
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 3.20.4
>            Reporter: Pasquale Congiusti
>            Priority: Major
>
> Hello team. While troubleshooting this Camel K issue [1], I've realized we're 
> missing some route event that can tell us that the route was completed. Do 
> you think it would be possible to include the `RouteCompleted` event? From 
> what I can tell, it would be an event generated once all the steps of the 
> route are completed. Without that, we don't know exactly when a route is 
> terminated and it's fine to gracefully stop it.
> Any feedback or possible workaround is appreciated as well, thanks!
> [1] https://github.com/apache/camel-k/issues/4343



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to