Hi all,

In Camel, messages can flow between routes through several components like:

1) Direct (Synchronous within CamelContext)
2) Direct-VM (Synchronous within JVM)
3) SEDA  (Asynchronous within CamelContext)
4) VM  (Asynchronous within JVM)
5) ActiveMQ/AMQP/SJMS/RabbitMQ (Synchronous/Asynchronous between JVM's)
6) Spring Events (invoked the same thread as Spring notifies events)


I have several questions regarding these various options.

There is a page in the FAQ:

https://camel.apache.org/manual/faq/how-do-the-direct-event-seda-and-vm-endpoints-compare.html

This page is however not very extensive and only explains it theoretically.
Is there a practical guide when to choose which option?


Some questions:

1) When to use synchronous or asynchronous?

In what use case should we choose synchronous and what use cases
asynchronous. For example should I choose "synchronous" when
using a request/reply pattern and want to wait for the answer and
asynchronous in other use cases?

2) Are the performance issues to take into consideration?

I have environments that use 10.000+ routes. Should I take performance
considerations when choosing any one of options?

3) When to choose between Direct and Direct-VM?

Can't I use "Direct-VM" in all cases for synchronous invocation and "VM"
for asynchronous invocation? "VM" work within the CamelContext AND
JVM? Is there a performance penalty when choosing "Direct-VM" instead of
"Direct"? Or "VM" or "Seda"?

4) Is "Direct" really synchronous?

By default "Synchronous" is false. In the documentation:

"Whether synchronous processing is forced. If enabled then the producer
thread, will be forced to wait until the message has been completed before
the same thread will continue processing. If disabled (default) then the
producer thread may be freed and can do other work while the message is
continued processed by other threads (reactive)."

Does reactive mean here it's non-blocking (and can process multiple
synchronous calls) or is it asynchronous in disguise?

5) Why the naming of the components?

In synchronous it's called

direct and direct-vm

But asynchronous is called

seda and vm

Shouldn't be called "seda-vm". Or why are there just these options:

sync
async
reactive

6) Using "Direct" vs "Keeping everything in one route"

I ran into this code:

<route>
    <from uri="file:a"/>
    <setHeader name="headerA">
        <constant>testA</constant>
    </setHeader>
    <to uri="direct:a"/>
</route>
<route>
    <from uri="direct:a"/>
    <setHeader name="headerB">
        <constant>testB</constant>
    </setHeader>
    <to uri="direct:b"/>
</route>
<route>
    <from uri="file:a"/>
    <setHeader name="headerC">
        <constant>testC</constant>
    </setHeader>
    <to uri="http:myendpoint"/>
</route>

Basically every route contains a "from" and "to" and only one action (in
this case a setheader step). I believe this was done, because the routes
were generated and the order can be changed easily. How I normally would
write this:

<route>
    <from uri="file:a"/>
    <setHeader name="headerA">
        <constant>testA</constant>
    </setHeader>
    <setHeader name="headerB">
        <constant>testB</constant>
    </setHeader>
    <setHeader name="headerC">
        <constant>testC</constant>
    </setHeader>
    <to uri="http:myendpoint"/>
</route>

Are there differences between the first three routes and the second
(everything in one route)? Is it just a different way of
organizing the code or are there actually difference in the way it works?
For example, is the second faster than the first (say I send 10 million
messages)? Does
using direct have advantages in the sense that it for example buffers
messages in its "internal queue"?

Regards,

Raymond

Reply via email to