Class SedaEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.seda.SedaEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.AsyncEndpoint, org.apache.camel.CamelContextAware, org.apache.camel.ComponentAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.MultipleConsumersSupport, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.BrowsableEndpoint, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@ManagedResource(description="Managed SedaEndpoint") @UriEndpoint(firstVersion="1.1.0", scheme="seda", title="SEDA", syntax="seda:name", remote=false, category={CORE,MESSAGING}) public class SedaEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.AsyncEndpoint, org.apache.camel.spi.BrowsableEndpoint, org.apache.camel.MultipleConsumersSupport
Asynchronously call another endpoint from any Camel Context in the same JVM.
  • 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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueue<org.apache.camel.Exchange> queue)
     
    SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueue<org.apache.camel.Exchange> queue, int concurrentConsumers)
     
    SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueueFactory<org.apache.camel.Exchange> queueFactory, int concurrentConsumers)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    protected SedaConsumer
    createNewConsumer(org.apache.camel.Processor processor)
     
    org.apache.camel.PollingConsumer
     
    org.apache.camel.Producer
     
    protected BlockingQueue<org.apache.camel.Exchange>
     
    protected void
     
    protected void
     
    protected void
     
     
    int
     
    protected org.apache.camel.AsyncProcessor
     
    Returns the current active consumers on this endpoint
    int
     
    List<org.apache.camel.Exchange>
    Returns the current pending exchanges
     
    long
     
    int
     
    Returns the current active producers on this endpoint
    BlockingQueue<org.apache.camel.Exchange>
     
    Gets the QueueReference for this endpoint.
    int
     
    long
     
    org.apache.camel.WaitForTaskToComplete
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    void
    Purges the queue
    void
    setBlockWhenFull(boolean blockWhenFull)
    Whether a thread that sends messages to a full SEDA queue will block until the queue's capacity is no longer exhausted.
    void
    setConcurrentConsumers(int concurrentConsumers)
    Number of concurrent threads processing exchanges.
    void
    setDiscardIfNoConsumers(boolean discardIfNoConsumers)
    Whether the producer should discard the message (do not add the message to the queue), when sending to a queue with no active consumers.
    void
    setDiscardWhenFull(boolean discardWhenFull)
    Whether a thread that sends messages to a full SEDA queue will be discarded.
    void
    setFailIfNoConsumers(boolean failIfNoConsumers)
    Whether the producer should fail by throwing an exception, when sending to a queue with no active consumers.
    void
    setLimitConcurrentConsumers(boolean limitConcurrentConsumers)
    Whether to limit the number of concurrentConsumers to the maximum of 500.
    void
    setMultipleConsumers(boolean multipleConsumers)
    Specifies whether multiple consumers are allowed.
    void
    setOfferTimeout(long offerTimeout)
    Offer timeout (in milliseconds) can be added to the block case when queue is full.
    void
    setPollTimeout(int pollTimeout)
    The timeout (in milliseconds) used when polling.
    void
    setPurgeWhenStopping(boolean purgeWhenStopping)
    Whether to purge the task queue when stopping the consumer/route.
    void
    setQueue(BlockingQueue<org.apache.camel.Exchange> queue)
    Define the queue instance which will be used by the endpoint.
    void
    setSize(int size)
    The maximum capacity of the SEDA queue (i.e., the number of messages it can hold).
    void
    setTimeout(long timeout)
    Timeout (in milliseconds) before a SEDA producer will stop waiting for an asynchronous task to complete.
    void
    setWaitForTaskToComplete(org.apache.camel.WaitForTaskToComplete waitForTaskToComplete)
    Option to specify whether the caller should wait for the async task to complete or not before continuing.
    void
     
    void
     
    protected void
     

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

    configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, 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, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, start, suspend

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.ComponentAware

    getComponent, setComponent

    Methods inherited from interface org.apache.camel.Endpoint

    configureExchange, configureProperties, createAsyncProducer, createExchange, createExchange, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, getExchangePattern, isLenientProperties, isSingletonProducer, setCamelContext

    Methods inherited from interface org.apache.camel.IsSingleton

    isSingleton

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start

    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 Details

    • SedaEndpoint

      public SedaEndpoint()
    • SedaEndpoint

      public SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueue<org.apache.camel.Exchange> queue)
    • SedaEndpoint

      public SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueue<org.apache.camel.Exchange> queue, int concurrentConsumers)
    • SedaEndpoint

      public SedaEndpoint(String endpointUri, org.apache.camel.Component component, BlockingQueueFactory<org.apache.camel.Exchange> queueFactory, int concurrentConsumers)
  • Method Details

    • getComponent

      public SedaComponent getComponent()
      Specified by:
      getComponent in interface org.apache.camel.ComponentAware
      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
    • createNewConsumer

      protected SedaConsumer createNewConsumer(org.apache.camel.Processor processor)
    • createPollingConsumer

      public org.apache.camel.PollingConsumer createPollingConsumer() throws Exception
      Specified by:
      createPollingConsumer in interface org.apache.camel.Endpoint
      Overrides:
      createPollingConsumer in class org.apache.camel.support.DefaultEndpoint
      Throws:
      Exception
    • getQueue

      public BlockingQueue<org.apache.camel.Exchange> getQueue()
    • createQueue

      protected BlockingQueue<org.apache.camel.Exchange> createQueue()
    • getQueueReference

      public QueueReference getQueueReference()
      Gets the QueueReference for this endpoint.
      Returns:
      the reference, or null if no queue reference exists.
    • getConsumerMulticastProcessor

      protected org.apache.camel.AsyncProcessor getConsumerMulticastProcessor()
    • updateMulticastProcessor

      protected void updateMulticastProcessor() throws Exception
      Throws:
      Exception
    • getName

      @ManagedAttribute(description="Queue name") public String getName()
    • setQueue

      public void setQueue(BlockingQueue<org.apache.camel.Exchange> queue)
      Define the queue instance which will be used by the endpoint.

      This option is only for rare use-cases where you want to use a custom queue instance.

    • getSize

      @ManagedAttribute(description="Queue max capacity") public int getSize()
    • setSize

      public void setSize(int size)
      The maximum capacity of the SEDA queue (i.e., the number of messages it can hold). Will by default use the defaultSize set on the SEDA component.
    • getCurrentQueueSize

      @ManagedAttribute(description="Current queue size") public int getCurrentQueueSize()
    • setBlockWhenFull

      public void setBlockWhenFull(boolean blockWhenFull)
      Whether a thread that sends messages to a full SEDA queue will block until the queue's capacity is no longer exhausted. By default, an exception will be thrown stating that the queue is full. By enabling this option, the calling thread will instead block and wait until the message can be accepted.
    • isBlockWhenFull

      @ManagedAttribute(description="Whether the caller will block sending to a full queue") public boolean isBlockWhenFull()
    • setDiscardWhenFull

      public void setDiscardWhenFull(boolean discardWhenFull)
      Whether a thread that sends messages to a full SEDA queue will be discarded. By default, an exception will be thrown stating that the queue is full. By enabling this option, the calling thread will give up sending and continue, meaning that the message was not sent to the SEDA queue.
    • isDiscardWhenFull

      @ManagedAttribute(description="Whether the caller will discard sending to a full queue") public boolean isDiscardWhenFull()
    • setConcurrentConsumers

      public void setConcurrentConsumers(int concurrentConsumers)
      Number of concurrent threads processing exchanges.
    • getConcurrentConsumers

      @ManagedAttribute(description="Number of concurrent consumers") public int getConcurrentConsumers()
    • isLimitConcurrentConsumers

      @ManagedAttribute public boolean isLimitConcurrentConsumers()
    • setLimitConcurrentConsumers

      public void setLimitConcurrentConsumers(boolean limitConcurrentConsumers)
      Whether to limit the number of concurrentConsumers to the maximum of 500. By default, an exception will be thrown if an endpoint is configured with a greater number. You can disable that check by turning this option off.
    • getWaitForTaskToComplete

      public org.apache.camel.WaitForTaskToComplete getWaitForTaskToComplete()
    • setWaitForTaskToComplete

      public void setWaitForTaskToComplete(org.apache.camel.WaitForTaskToComplete waitForTaskToComplete)
      Option to specify whether the caller should wait for the async task to complete or not before continuing. The following three options are supported: Always, Never or IfReplyExpected. The first two values are self-explanatory. The last value, IfReplyExpected, will only wait if the message is Request Reply based. The default option is IfReplyExpected.
    • getTimeout

      @ManagedAttribute public long getTimeout()
    • setTimeout

      public void setTimeout(long timeout)
      Timeout (in milliseconds) before a SEDA producer will stop waiting for an asynchronous task to complete. You can disable timeout by using 0 or a negative value.
    • getOfferTimeout

      @ManagedAttribute public long getOfferTimeout()
    • setOfferTimeout

      public void setOfferTimeout(long offerTimeout)
      Offer timeout (in milliseconds) can be added to the block case when queue is full. You can disable timeout by using 0 or a negative value.
    • isFailIfNoConsumers

      @ManagedAttribute public boolean isFailIfNoConsumers()
    • setFailIfNoConsumers

      public void setFailIfNoConsumers(boolean failIfNoConsumers)
      Whether the producer should fail by throwing an exception, when sending to a queue with no active consumers.

      Only one of the options discardIfNoConsumers and failIfNoConsumers can be enabled at the same time.

    • isDiscardIfNoConsumers

      @ManagedAttribute public boolean isDiscardIfNoConsumers()
    • setDiscardIfNoConsumers

      public void setDiscardIfNoConsumers(boolean discardIfNoConsumers)
      Whether the producer should discard the message (do not add the message to the queue), when sending to a queue with no active consumers.

      Only one of the options discardIfNoConsumers and failIfNoConsumers can be enabled at the same time.

    • isMultipleConsumers

      @ManagedAttribute public boolean isMultipleConsumers()
    • setMultipleConsumers

      public void setMultipleConsumers(boolean multipleConsumers)
      Specifies whether multiple consumers are allowed. If enabled, you can use SEDA for Publish-Subscribe messaging. That is, you can send a message to the SEDA queue and have each consumer receive a copy of the message. When enabled, this option should be specified on every consumer endpoint.
    • getPollTimeout

      @ManagedAttribute public int getPollTimeout()
    • setPollTimeout

      public void setPollTimeout(int pollTimeout)
      The timeout (in milliseconds) used when polling. When a timeout occurs, the consumer can check whether it is allowed to continue running. Setting a lower value allows the consumer to react more quickly upon shutdown.
    • isPurgeWhenStopping

      @ManagedAttribute public boolean isPurgeWhenStopping()
    • setPurgeWhenStopping

      public void setPurgeWhenStopping(boolean purgeWhenStopping)
      Whether to purge the task queue when stopping the consumer/route. This allows to stop faster, as any pending messages on the queue is discarded.
    • getExchanges

      public List<org.apache.camel.Exchange> getExchanges()
      Returns the current pending exchanges
      Specified by:
      getExchanges in interface org.apache.camel.spi.BrowsableEndpoint
    • isMultipleConsumersSupported

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

      @ManagedOperation(description="Purges the seda queue") public void purgeQueue()
      Purges the queue
    • getConsumers

      public Set<SedaConsumer> getConsumers()
      Returns the current active consumers on this endpoint
    • getProducers

      public Set<SedaProducer> getProducers()
      Returns the current active producers on this endpoint
    • hasConsumers

      public boolean hasConsumers()
    • doInit

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

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • stop

      public void stop()
      Specified by:
      stop in interface org.apache.camel.Service
      Overrides:
      stop in class org.apache.camel.support.service.BaseService
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface org.apache.camel.ShutdownableService
      Overrides:
      shutdown in class org.apache.camel.support.service.BaseService
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception