Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ordinary Queue vs SEDA Queue

Being new to Apache Camel, I was recently reviewing its long list of components and stumbled upon their support for SEDA queue components.

The page didn't make much sense to me, so I did a couple of online searches for the term "SEDA queue" and got the wikipedia article here.

After reading that article, I can't tell what the difference is between a SEDA queue and a normal, "ordinary" queue! Both embrace the notion of decoupling systems through the use of asynchronous queues.

From the article, "SEDA" just sounds like an architecture that consists of placing a queue between each component. Is this correct?

But if it's just an architecture, then why is a "SEDA" queue a special Apache Camel component?

like image 918
IAmYourFaja Avatar asked Feb 06 '12 14:02

IAmYourFaja


People also ask

What is a SEDA queue?

The staged event-driven architecture (SEDA) refers to an approach to software architecture that decomposes a complex, event-driven application into a set of stages connected by queues.

What is direct and SEDA in camel?

While the Direct and Direct-VM components take a synchronous approach to joining routes, SEDA does the opposite. It allows routes to be connected in an asynchronous way; that is, when a Camel route publishes a message to a seda: endpoint, the message is sent and control is returned immediately to the calling route.

What is SEDA component in camel?

The SEDA component provides asynchronous SEDA behavior, so that messages are exchanged on a BlockingQueue and consumers are invoked in a separate thread from the producer. Note that queues are only visible within a single CamelContext.

What is queue in Apache Camel?

You use a Queue for point-to-point and Topic for a publish-subscribe model. On a Java platform, JMS - Java Messaging Service provides an interface to a messaging server. Apache activeMQ is one such open source JMS provider. Camel does not ship with a JMS provider; however, it can be configured to use activeMQ.

What is direct-VM in camel?

The Direct-Vm component provides direct, synchronous invocation of any consumers in the JVM when a producer sends a message exchange. This endpoint can be used to connect existing routes in the same camel context, as well from other camel contexts in the same JVM.


2 Answers

SEDA is an acronym that stands for Staged Event Driven Architecture it is designed as a mechanism to regulate the flow between different phases of message processing. The idea is to smooth out the frequency of message output from an overall process so that it matches the input, It allows an enpoint´s consumer threads to offload the work of long-running operations into the background, thereby freeing them up to consume messages from the transport. When an exchange is passed to a seda: endpoint, it is placed into a BlockingQueue. The list exists within the Camel context, wich means that only those routes that are within the same context can be joined by this type of endpoint. The queue is unbounded by default, although that can be changed by setting the size attribute on the URI of the consumer.

By default, a single thread assigned to the endpoint reads exchanges off the list and processes them through the route. As seen in the proceding example, it is possible to increase the number of concurrenctConsumers to ensure that exchanges are getting processed from that list in a timely fashion.

The SEDA pattern is best suited to processing the InOnly messages, where one route finishes processing and hands off to another to deal with the next phase. It is possible to ask for a response from seda:endpoint by calling it when the message exchange pattern is InOut.

Reference: Apache Camel Developer´s Cookbook

like image 160
castilloRT Avatar answered Oct 11 '22 11:10

castilloRT


SEDA queues are just like a regular queue (and as Peter said above, in Camel they have a thread pool associated with them as part of the component). SEDA is an architecture. The SEDA component in Camel uses in-memory queues in your process and are a separate component in order to distinguish them from the other queue component in Apache camel, namely the JMS component.

like image 29
gregwhitaker Avatar answered Oct 11 '22 12:10

gregwhitaker