Skip to content

Commit

Permalink
CAMEL-8023: Model and component javadoc documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Feb 9, 2015
1 parent 35cc890 commit e7f0126
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
Expand Up @@ -36,7 +36,7 @@ public class SedaComponent extends UriEndpointComponent {
protected final Logger log = LoggerFactory.getLogger(getClass()); protected final Logger log = LoggerFactory.getLogger(getClass());
protected final int maxConcurrentConsumers = 500; protected final int maxConcurrentConsumers = 500;
protected int queueSize; protected int queueSize;
protected int defaultConcurrentConsumers = 1; protected int concurrentConsumers = 1;
private final Map<String, QueueReference> queues = new HashMap<String, QueueReference>(); private final Map<String, QueueReference> queues = new HashMap<String, QueueReference>();
private BlockingQueueFactory<Exchange> defaultQueueFactory = new LinkedBlockingQueueFactory<Exchange>(); private BlockingQueueFactory<Exchange> defaultQueueFactory = new LinkedBlockingQueueFactory<Exchange>();


Expand All @@ -48,26 +48,35 @@ public SedaComponent(Class<? extends Endpoint> endpointClass) {
super(endpointClass); super(endpointClass);
} }


/**
* Sets the default maximum capacity of the SEDA queue (i.e., the number of messages it can hold).
*/
public void setQueueSize(int size) { public void setQueueSize(int size) {
queueSize = size; queueSize = size;
} }


public int getQueueSize() { public int getQueueSize() {
return queueSize; return queueSize;
} }


/**
* Sets the default number of concurrent threads processing exchanges.
*/
public void setConcurrentConsumers(int size) { public void setConcurrentConsumers(int size) {
defaultConcurrentConsumers = size; concurrentConsumers = size;
} }


public int getConcurrentConsumers() { public int getConcurrentConsumers() {
return defaultConcurrentConsumers; return concurrentConsumers;
} }


public BlockingQueueFactory<Exchange> getDefaultQueueFactory() { public BlockingQueueFactory<Exchange> getDefaultQueueFactory() {
return defaultQueueFactory; return defaultQueueFactory;
} }


/**
* Sets the default queue factory.
*/
public void setDefaultQueueFactory(BlockingQueueFactory<Exchange> defaultQueueFactory) { public void setDefaultQueueFactory(BlockingQueueFactory<Exchange> defaultQueueFactory) {
this.defaultQueueFactory = defaultQueueFactory; this.defaultQueueFactory = defaultQueueFactory;
} }
Expand Down Expand Up @@ -155,7 +164,7 @@ public QueueReference getQueueReference(String key) {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
int consumers = getAndRemoveParameter(parameters, "concurrentConsumers", Integer.class, defaultConcurrentConsumers); int consumers = getAndRemoveParameter(parameters, "concurrentConsumers", Integer.class, concurrentConsumers);
boolean limitConcurrentConsumers = getAndRemoveParameter(parameters, "limitConcurrentConsumers", Boolean.class, true); boolean limitConcurrentConsumers = getAndRemoveParameter(parameters, "limitConcurrentConsumers", Boolean.class, true);
if (limitConcurrentConsumers && consumers > maxConcurrentConsumers) { if (limitConcurrentConsumers && consumers > maxConcurrentConsumers) {
throw new IllegalArgumentException("The limitConcurrentConsumers flag in set to true. ConcurrentConsumers cannot be set at a value greater than " throw new IllegalArgumentException("The limitConcurrentConsumers flag in set to true. ConcurrentConsumers cannot be set at a value greater than "
Expand Down
Expand Up @@ -236,6 +236,11 @@ protected synchronized void updateMulticastProcessor() throws Exception {
} }
} }


/**
* Define the queue instance which will be used by seda endpoint.
* <p/>
* This option is only for rare use-cases where you want to use a custom queue instance.
*/
public void setQueue(BlockingQueue<Exchange> queue) { public void setQueue(BlockingQueue<Exchange> queue) {
this.queue = queue; this.queue = queue;
this.size = queue.remainingCapacity(); this.size = queue.remainingCapacity();
Expand All @@ -246,6 +251,9 @@ public int getSize() {
return size; return size;
} }


/**
* The maximum capacity of the SEDA queue (i.e., the number of messages it can hold).
*/
public void setSize(int size) { public void setSize(int size) {
this.size = size; this.size = size;
} }
Expand All @@ -255,6 +263,11 @@ public int getCurrentQueueSize() {
return queue.size(); return queue.size();
} }


/**
* 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.
*/
public void setBlockWhenFull(boolean blockWhenFull) { public void setBlockWhenFull(boolean blockWhenFull) {
this.blockWhenFull = blockWhenFull; this.blockWhenFull = blockWhenFull;
} }
Expand All @@ -264,6 +277,9 @@ public boolean isBlockWhenFull() {
return blockWhenFull; return blockWhenFull;
} }


/**
* Number of concurrent threads processing exchanges.
*/
public void setConcurrentConsumers(int concurrentConsumers) { public void setConcurrentConsumers(int concurrentConsumers) {
this.concurrentConsumers = concurrentConsumers; this.concurrentConsumers = concurrentConsumers;
} }
Expand All @@ -277,6 +293,13 @@ public WaitForTaskToComplete getWaitForTaskToComplete() {
return waitForTaskToComplete; return 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.
*/
public void setWaitForTaskToComplete(WaitForTaskToComplete waitForTaskToComplete) { public void setWaitForTaskToComplete(WaitForTaskToComplete waitForTaskToComplete) {
this.waitForTaskToComplete = waitForTaskToComplete; this.waitForTaskToComplete = waitForTaskToComplete;
} }
Expand All @@ -286,6 +309,10 @@ public long getTimeout() {
return timeout; return 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.
*/
public void setTimeout(long timeout) { public void setTimeout(long timeout) {
this.timeout = timeout; this.timeout = timeout;
} }
Expand All @@ -295,6 +322,9 @@ public boolean isFailIfNoConsumers() {
return failIfNoConsumers; return failIfNoConsumers;
} }


/**
* Whether the producer should fail by throwing an exception, when sending to a SEDA queue with no active consumers.
*/
public void setFailIfNoConsumers(boolean failIfNoConsumers) { public void setFailIfNoConsumers(boolean failIfNoConsumers) {
this.failIfNoConsumers = failIfNoConsumers; this.failIfNoConsumers = failIfNoConsumers;
} }
Expand All @@ -304,6 +334,11 @@ public boolean isMultipleConsumers() {
return multipleConsumers; return 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.
*/
public void setMultipleConsumers(boolean multipleConsumers) { public void setMultipleConsumers(boolean multipleConsumers) {
this.multipleConsumers = multipleConsumers; this.multipleConsumers = multipleConsumers;
} }
Expand All @@ -313,6 +348,10 @@ public int getPollTimeout() {
return pollTimeout; return 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.
*/
public void setPollTimeout(int pollTimeout) { public void setPollTimeout(int pollTimeout) {
this.pollTimeout = pollTimeout; this.pollTimeout = pollTimeout;
} }
Expand All @@ -322,6 +361,10 @@ public boolean isPurgeWhenStopping() {
return purgeWhenStopping; return 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.
*/
public void setPurgeWhenStopping(boolean purgeWhenStopping) { public void setPurgeWhenStopping(boolean purgeWhenStopping) {
this.purgeWhenStopping = purgeWhenStopping; this.purgeWhenStopping = purgeWhenStopping;
} }
Expand Down

0 comments on commit e7f0126

Please sign in to comment.