Interface InflightRepository

All Superinterfaces:
AutoCloseable, Service, StaticService

public interface InflightRepository extends StaticService
A live registry that tracks every Exchange that is currently being processed within the CamelContext.

The routing engine calls add(org.apache.camel.Exchange) when an exchange enters processing and remove(org.apache.camel.Exchange) when it completes (successfully or with failure). Per-route counts are available via size(String); the full list of inflight exchanges is accessible via browse(), which returns InflightRepository.InflightExchange snapshots with elapsed-time and duration metrics. ShutdownStrategy polls this repository to wait until the inflight count reaches zero before completing a graceful shutdown. The JMX management layer and developer console expose the inflight data for operational visibility.

See Graceful Shutdown in the Camel user manual.

See Also:
  • Method Details

    • add

      void add(Exchange exchange)
      Adds the exchange to the inflight registry to the total counter
      Parameters:
      exchange - the exchange
    • remove

      void remove(Exchange exchange)
      Removes the exchange from the inflight registry to the total counter
      Parameters:
      exchange - the exchange
    • add

      void add(Exchange exchange, String routeId)
      Adds the exchange to the inflight registry associated to the given route
      Parameters:
      exchange - the exchange
      routeId - the id of the route
    • remove

      void remove(Exchange exchange, String routeId)
      Removes the exchange from the inflight registry removing association to the given route
      Parameters:
      exchange - the exchange
      routeId - the id of the route
    • size

      int size()
      Current size of inflight exchanges.

      Will return 0 if there are no inflight exchanges.

      Returns:
      number of exchanges currently in flight.
    • addRoute

      void addRoute(String routeId)
      Adds the route from the in flight registry.

      Is used for initializing up resources

      Parameters:
      routeId - the id of the route
    • removeRoute

      void removeRoute(String routeId)
      Removes the route from the in flight registry.

      Is used for cleaning up resources to avoid leaking.

      Parameters:
      routeId - the id of the route
    • size

      int size(String routeId)
      Current size of inflight exchanges which are from the given route.

      Will return 0 if there are no inflight exchanges.

      Parameters:
      routeId - the id of the route
      Returns:
      number of exchanges currently in flight.
    • isInflightBrowseEnabled

      boolean isInflightBrowseEnabled()
      Whether the inflight repository should allow browsing each inflight exchange. This is by default disabled as there is a very slight performance overhead when enabled.
    • setInflightBrowseEnabled

      void setInflightBrowseEnabled(boolean inflightBrowseEnabled)
      Whether the inflight repository should allow browsing each inflight exchange. This is by default disabled as there is a very slight performance overhead when enabled.
      Parameters:
      inflightBrowseEnabled - whether browsing is enabled
    • browse

      A read-only browser of the InflightRepository.InflightExchanges that are currently inflight.
    • browse

      Collection<InflightRepository.InflightExchange> browse(@Nullable String fromRouteId)
      A read-only browser of the InflightRepository.InflightExchanges that are currently inflight that started from the given route.
      Parameters:
      fromRouteId - the route id, or null for all routes.
    • browse

      Collection<InflightRepository.InflightExchange> browse(int limit, boolean sortByLongestDuration)
      A read-only browser of the InflightRepository.InflightExchanges that are currently inflight.
      Parameters:
      limit - maximum number of entries to return
      sortByLongestDuration - to sort by the longest duration. Set to true to include the exchanges that has been inflight the longest time, set to false to sort by exchange id
    • browse

      Collection<InflightRepository.InflightExchange> browse(@Nullable String fromRouteId, int limit, boolean sortByLongestDuration)
      A read-only browser of the InflightRepository.InflightExchanges that are currently inflight that started from the given route.
      Parameters:
      fromRouteId - the route id, or null for all routes.
      limit - maximum number of entries to return
      sortByLongestDuration - to sort by the longest duration. Set to true to include the exchanges that has been inflight the longest time, set to false to sort by exchange id
    • oldest

      @Nullable InflightRepository.InflightExchange oldest(@Nullable String fromRouteId)
      Gets the oldest InflightRepository.InflightExchange that are currently inflight that started from the given route.
      Parameters:
      fromRouteId - the route id, or null for all routes.
      Returns:
      the oldest, or null if none inflight