Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip
titleSynchronous

The Direct component provides synchronous invocation of any consumers when a producer sends a message exchange.

URI format

Code Block

seda:someName[?options]

Where someName can be any string that uniquely identifies the endpoint within the current CamelContext.

...

By default, the SEDA component always intantiates LinkedBlockingQueue, but you can use different implementation, you can reference your own BlockingQueue implementation, in this case the size option is not used

Code Block

<bean id="arrayQueue" class="java.util.ArrayBlockingQueue">
<constructor-arg index="0" value="10" ><!-- size -->
<constructor-arg index="1" value="true" ><!-- fairness -->
</bean>
<!-- ... and later -->
<from>seda:array?queue=#arrayQueue</from>

Or you can reference a BlockingQueueFactory implementation, 3 implementations are provided LinkedBlockingQueueFactory, ArrayBlockingQueueFactory and PriorityBlockingQueueFactory:

Code Block

<bean id="priorityQueueFactory" class="org.apache.camel.component.seda.PriorityBlockingQueueFactory">
<property name="comparator">
<bean class="org.apache.camel.demo.MyExchangeComparator" />
</property>
</bean>
<!-- ... and later -->
<from>seda:priority?queueFactory=#priorityQueueFactory&size=100</from>

Use of Request Reply

The Seda SEDA component supports using Request Reply, where the caller will wait for the Async route to complete. For instance:

Code Block

from("mina:tcp://0.0.0.0:9876?textline=true&sync=true").to("seda:input");

from("seda:input").to("bean:processInput").to("bean:createResponse");

...

By default, the SEDA endpoint uses a single consumer thread, but you can configure it to use concurrent consumer threads. So instead of thread pools you can use:

Code Block

from("seda:stageName?concurrentConsumers=5").process(...)

...

Be aware that adding a thread pool to a SEDA endpoint by doing something like:

Code Block

from("seda:stageName").thread(5).process(...)

Can wind up with two BlockQueues: one from the SEDA endpoint, and one from the workqueue of the thread pool, which may not be what you want. Instead, you might wish to configure a Direct endpoint with a thread pool, which can process messages both synchronously and asynchronously. For example:

Code Block

from("direct:stageName").thread(5).process(...)

...

If needed, information such as queue size, etc. can be obtained without using JMX in this fashion:

Code Block

SedaEndpoint seda = context.getEndpoint("seda:xxxx");
int size = seda.getExchanges().size();

Include Page
Endpoint See Also
Endpoint See Also