Class TimerEndpoint

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.MultipleConsumersSupport, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @ManagedResource(description="Managed TimerEndpoint")
    @UriEndpoint(firstVersion="1.0.0",
                 scheme="timer",
                 title="Timer",
                 syntax="timer:timerName",
                 consumerOnly=true,
                 category={CORE,SCHEDULING})
    public class TimerEndpoint
    extends org.apache.camel.support.DefaultEndpoint
    implements org.apache.camel.MultipleConsumersSupport
    Generate messages in specified intervals using java.util.Timer. This component is similar to the scheduler component, but has much less functionality.
    • Field Summary

      • 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
      org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)  
      org.apache.camel.Producer createProducer()  
      protected void doInit()  
      protected void doStop()  
      TimerComponent getComponent()  
      long getDelay()  
      String getPattern()  
      long getPeriod()  
      long getRepeatCount()  
      Date getTime()  
      Timer getTimer()  
      Timer getTimer​(TimerConsumer consumer)  
      String getTimerName()  
      boolean isDaemon()  
      boolean isFixedRate()  
      boolean isIncludeMetadata()  
      boolean isMultipleConsumersSupported()  
      boolean isSynchronous()  
      void removeTimer​(TimerConsumer consumer)  
      void setDaemon​(boolean daemon)
      Specifies whether or not the thread associated with the timer endpoint runs as a daemon.
      void setDelay​(long delay)
      The number of milliseconds to wait before the first event is generated.
      void setFixedRate​(boolean fixedRate)
      Events take place at approximately regular intervals, separated by the specified period.
      void setIncludeMetadata​(boolean includeMetadata)
      Whether to include metadata in the exchange such as fired time, timer name, timer count etc.
      void setPattern​(String pattern)
      Allows you to specify a custom Date pattern to use for setting the time option using URI syntax.
      void setPeriod​(long period)
      If greater than 0, generate periodic events every period milliseconds.
      void setRepeatCount​(long repeatCount)
      Specifies a maximum limit of number of fires.
      void setSynchronous​(boolean synchronous)  
      void setTime​(Date time)
      A java.util.Date the first event should be generated.
      void setTimer​(Timer timer)
      To use a custom Timer
      void setTimerName​(String timerName)
      The name of the timer
      • Methods inherited from class org.apache.camel.support.DefaultEndpoint

        configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doStart, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, 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.Endpoint

        getEndpointBaseUri, isSingletonProducer
      • 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

      • TimerEndpoint

        public TimerEndpoint()
      • TimerEndpoint

        public TimerEndpoint​(String uri,
                             org.apache.camel.Component component,
                             String timerName)
      • TimerEndpoint

        protected TimerEndpoint​(String endpointUri,
                                org.apache.camel.Component component)
    • Method Detail

      • getComponent

        public TimerComponent getComponent()
        Overrides:
        getComponent in class org.apache.camel.support.DefaultEndpoint
      • createProducer

        public org.apache.camel.Producer createProducer()
                                                 throws Exception
        Specified by:
        createProducer in interface org.apache.camel.Endpoint
        Throws:
        Exception
      • createConsumer

        public org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)
                                                 throws Exception
        Specified by:
        createConsumer in interface org.apache.camel.Endpoint
        Throws:
        Exception
      • doInit

        protected void doInit()
                       throws Exception
        Overrides:
        doInit in class org.apache.camel.support.DefaultEndpoint
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.DefaultEndpoint
        Throws:
        Exception
      • isMultipleConsumersSupported

        @ManagedAttribute
        public boolean isMultipleConsumersSupported()
        Specified by:
        isMultipleConsumersSupported in interface org.apache.camel.MultipleConsumersSupport
      • getTimerName

        @ManagedAttribute(description="Timer Name")
        public String getTimerName()
      • setTimerName

        @ManagedAttribute(description="Timer Name")
        public void setTimerName​(String timerName)
        The name of the timer
      • isDaemon

        @ManagedAttribute(description="Timer Daemon")
        public boolean isDaemon()
      • setDaemon

        @ManagedAttribute(description="Timer Daemon")
        public void setDaemon​(boolean daemon)
        Specifies whether or not the thread associated with the timer endpoint runs as a daemon.

        The default value is true.

      • getDelay

        @ManagedAttribute(description="Timer Delay")
        public long getDelay()
      • setDelay

        @ManagedAttribute(description="Timer Delay")
        public void setDelay​(long delay)
        The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option.

        The default value is 1000.

      • isFixedRate

        @ManagedAttribute(description="Timer FixedRate")
        public boolean isFixedRate()
      • setFixedRate

        @ManagedAttribute(description="Timer FixedRate")
        public void setFixedRate​(boolean fixedRate)
        Events take place at approximately regular intervals, separated by the specified period.
      • getPeriod

        @ManagedAttribute(description="Timer Period")
        public long getPeriod()
      • setPeriod

        @ManagedAttribute(description="Timer Period")
        public void setPeriod​(long period)
        If greater than 0, generate periodic events every period milliseconds.

        The default value is 1000.

      • getRepeatCount

        @ManagedAttribute(description="Repeat Count")
        public long getRepeatCount()
      • setRepeatCount

        @ManagedAttribute(description="Repeat Count")
        public void setRepeatCount​(long repeatCount)
        Specifies a maximum limit of number of fires. So if you set it to 1, the timer will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever.
      • getTime

        public Date getTime()
      • setTime

        public void setTime​(Date time)
        A java.util.Date the first event should be generated. If using the URI, the pattern expected is: yyyy-MM-dd HH:mm:ss or yyyy-MM-dd'T'HH:mm:ss.
      • getPattern

        public String getPattern()
      • setPattern

        public void setPattern​(String pattern)
        Allows you to specify a custom Date pattern to use for setting the time option using URI syntax.
      • getTimer

        public Timer getTimer()
      • setTimer

        public void setTimer​(Timer timer)
        To use a custom Timer
      • isIncludeMetadata

        @ManagedAttribute(description="Include metadata")
        public boolean isIncludeMetadata()
      • setIncludeMetadata

        @ManagedAttribute(description="Include metadata")
        public void setIncludeMetadata​(boolean includeMetadata)
        Whether to include metadata in the exchange such as fired time, timer name, timer count etc. This information is default included.
      • isSynchronous

        public boolean isSynchronous()
      • setSynchronous

        public void setSynchronous​(boolean synchronous)
      • removeTimer

        public void removeTimer​(TimerConsumer consumer)