Package org.apache.camel.component.seda
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.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.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", category={CORE,ENDPOINT}) 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.
-
-
Constructor Summary
Constructors Constructor Description SedaEndpoint()
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
All Methods Instance Methods Concrete Methods 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
createPollingConsumer()
org.apache.camel.Producer
createProducer()
protected BlockingQueue<org.apache.camel.Exchange>
createQueue()
protected void
doInit()
protected void
doShutdown()
protected void
doStart()
SedaComponent
getComponent()
int
getConcurrentConsumers()
protected org.apache.camel.AsyncProcessor
getConsumerMulticastProcessor()
Set<SedaConsumer>
getConsumers()
Returns the current active consumers on this endpointint
getCurrentQueueSize()
List<org.apache.camel.Exchange>
getExchanges()
Returns the current pending exchangeslong
getOfferTimeout()
int
getPollTimeout()
Set<SedaProducer>
getProducers()
Returns the current active producers on this endpointBlockingQueue<org.apache.camel.Exchange>
getQueue()
QueueReference
getQueueReference()
Get's theQueueReference
for the this endpoint.int
getSize()
long
getTimeout()
org.apache.camel.WaitForTaskToComplete
getWaitForTaskToComplete()
boolean
hasConsumers()
boolean
isBlockWhenFull()
boolean
isDiscardIfNoConsumers()
boolean
isDiscardWhenFull()
boolean
isFailIfNoConsumers()
boolean
isLimitConcurrentConsumers()
boolean
isMultipleConsumers()
boolean
isMultipleConsumersSupported()
boolean
isPurgeWhenStopping()
void
purgeQueue()
Purges the queuevoid
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)
offerTimeout (in milliseconds) can be added to the block case when queue is full.void
setPollTimeout(int pollTimeout)
The timeout 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
shutdown()
void
stop()
protected void
updateMulticastProcessor()
-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, doStop, 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, 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.Endpoint
configureExchange, configureProperties, createAsyncProducer, createExchange, createExchange, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, isLenientProperties, isSingletonProducer, setCamelContext
-
-
-
-
Constructor Detail
-
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 Detail
-
getComponent
public SedaComponent getComponent()
- Overrides:
getComponent
in classorg.apache.camel.support.DefaultEndpoint
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.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 interfaceorg.apache.camel.Endpoint
- Overrides:
createPollingConsumer
in classorg.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()
Get's theQueueReference
for the this endpoint.- Returns:
- the reference, or null if no queue reference exists.
-
getConsumerMulticastProcessor
protected org.apache.camel.AsyncProcessor getConsumerMulticastProcessor() throws Exception
- Throws:
Exception
-
updateMulticastProcessor
protected void updateMulticastProcessor() throws Exception
- Throws:
Exception
-
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)
offerTimeout (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 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 interfaceorg.apache.camel.spi.BrowsableEndpoint
-
isMultipleConsumersSupported
@ManagedAttribute public boolean isMultipleConsumersSupported()
- Specified by:
isMultipleConsumersSupported
in interfaceorg.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 classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
stop
public void stop()
- Specified by:
stop
in interfaceorg.apache.camel.Service
- Overrides:
stop
in classorg.apache.camel.support.service.BaseService
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceorg.apache.camel.ShutdownableService
- Overrides:
shutdown
in classorg.apache.camel.support.service.BaseService
-
-