What is the difference between SEDA, VM and direct in Apache Camel?

后端 未结 2 1822
迷失自我
迷失自我 2021-02-04 13:59

I had worked with both SEDA and direct, and I\'ve also read the documentation.

But I still cannot visualize the usage of SEDA and direct. Vm is new to me.

Pleas

2条回答
  •  被撕碎了的回忆
    2021-02-04 14:31

    The difference between direct: and seda: components is that the first is synchronous and the second is asynchronous, with a queue.

    The practical difference is that for sending synchronous messages, you must wait for the route to complete, whereas with asynchronous messages, its "fire and forget" - you put them onto a queue and presume a consumer will process them. You can also have multiple consumers (parallelisation).

    The last example, vm: is also asynchronous, but it can also call routes in different camel contexts within the same JVM. Imagine application 1 has a camel context, and application 2 has a camel context, in this way they can communicate with each other.

    edit:

    In relation to "what to use when" :

    • use direct: for calling normally between endpoints in a camel context
    • use seda: when you need parallelisation or queues, but dont want to use jms:
    • use vm: when calling between applications.

    There are of course many other use cases but those are the common ones (subjective to my own experience)

提交回复
热议问题