Class MetricsRoutePolicy

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.RoutePolicySupport
org.apache.camel.component.metrics.routepolicy.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 final String
     
    static final String
     
    static final String
     

    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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    com.codahale.metrics.MetricRegistry
     
     
     
    boolean
     
    boolean
     
    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
     
    void
    setUseJmx(boolean useJmx)
     

    Methods inherited from class org.apache.camel.support.RoutePolicySupport

    controller, 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, doStart, doStop, 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 class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    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
  • Field Details

  • Constructor Details

    • MetricsRoutePolicy

      public MetricsRoutePolicy()
  • Method Details

    • 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