Class MetricsRoutePolicy

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.NonManagedService, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.RoutePolicy, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    public class MetricsRoutePolicy
    extends org.apache.camel.support.RoutePolicySupport
    implements org.apache.camel.NonManagedService
    A RoutePolicy which gathers statistics and reports them using MetricRegistry.

    The metrics is reported in JMX by default, but this can be configured.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String NAME_TOKEN  
      static String ROUTE_ID_TOKEN  
      static String TYPE_TOKEN  
      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TimeUnit getDurationUnit()  
      String getJmxDomain()  
      com.codahale.metrics.MetricRegistry getMetricsRegistry()  
      String getNamePattern()  
      TimeUnit getRateUnit()  
      boolean isPrettyPrint()  
      boolean isUseJmx()  
      void onExchangeBegin​(org.apache.camel.Route route, org.apache.camel.Exchange exchange)  
      void onExchangeDone​(org.apache.camel.Route route, org.apache.camel.Exchange exchange)  
      void onInit​(org.apache.camel.Route route)  
      void setDurationUnit​(TimeUnit durationUnit)  
      void setJmxDomain​(String jmxDomain)  
      void setMetricsRegistry​(com.codahale.metrics.MetricRegistry metricsRegistry)  
      void setNamePattern​(String namePattern)
      The name pattern to use.
      void setPrettyPrint​(boolean prettyPrint)  
      void setRateUnit​(TimeUnit rateUnit)  
      void setUseJmx​(boolean useJmx)  
      • Methods inherited from class org.apache.camel.support.RoutePolicySupport

        controller, doStart, doStop, getExceptionHandler, handleException, onRemove, onResume, onStart, onStop, onSuspend, resumeOrStartConsumer, resumeRoute, setExceptionHandler, startConsumer, startRoute, stopConsumer, stopRoute, stopRoute, stopRouteAsync, suspendOrStopConsumer, suspendRoute, suspendRoute
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • MetricsRoutePolicy

        public MetricsRoutePolicy()
    • Method Detail

      • getMetricsRegistry

        public com.codahale.metrics.MetricRegistry getMetricsRegistry()
      • setMetricsRegistry

        public void setMetricsRegistry​(com.codahale.metrics.MetricRegistry metricsRegistry)
      • isUseJmx

        public boolean isUseJmx()
      • setUseJmx

        public void setUseJmx​(boolean useJmx)
      • getJmxDomain

        public String getJmxDomain()
      • setJmxDomain

        public void setJmxDomain​(String jmxDomain)
      • isPrettyPrint

        public boolean isPrettyPrint()
      • setPrettyPrint

        public void setPrettyPrint​(boolean prettyPrint)
      • getRateUnit

        public TimeUnit getRateUnit()
      • setRateUnit

        public void setRateUnit​(TimeUnit rateUnit)
      • getDurationUnit

        public TimeUnit getDurationUnit()
      • setDurationUnit

        public void setDurationUnit​(TimeUnit durationUnit)
      • getNamePattern

        public String getNamePattern()
      • setNamePattern

        public void setNamePattern​(String namePattern)
        The name pattern to use.

        Uses dot as separators, but you can change that. The values ##name##, ##routeId##, and ##type## will be replaced with actual value.

      • onInit

        public void onInit​(org.apache.camel.Route route)
        Specified by:
        onInit in interface org.apache.camel.spi.RoutePolicy
        Overrides:
        onInit in class org.apache.camel.support.RoutePolicySupport
      • onExchangeBegin

        public void onExchangeBegin​(org.apache.camel.Route route,
                                    org.apache.camel.Exchange exchange)
        Specified by:
        onExchangeBegin in interface org.apache.camel.spi.RoutePolicy
        Overrides:
        onExchangeBegin in class org.apache.camel.support.RoutePolicySupport
      • onExchangeDone

        public void onExchangeDone​(org.apache.camel.Route route,
                                   org.apache.camel.Exchange exchange)
        Specified by:
        onExchangeDone in interface org.apache.camel.spi.RoutePolicy
        Overrides:
        onExchangeDone in class org.apache.camel.support.RoutePolicySupport