14
votes

My understanding of Akka is that it provides a model whereby multiple, isolated threads can communicate with each other in a highly concurrent fashion. It uses the "actor model", where each thread is an "actor" with a specific job to do. You can orchestrate which messages get passed to which actors under what conditions.

I've used Camel before, and to me, I feel like it's sort of lost its luster/utility now that Akka is so mature and well documented. As I understand it, Camel is about enterprise integration, that is, integrating multiple disparate systems together, usually in some kind of service bus fashion.

But think about it: if I am currently using Camel to:

  • Poll an FTP server for a file, and once found...
  • Transform the contents of that file into a POJO, then...
  • Send out an email if the POJO has a certain state, or
  • Persist the POJO to a database in all other cases

I can do the exact same thing with Akka; I can have 1 Actor for each of those steps (Poll FTP, transform file -> POJO, email or persist), wire them together, and let Akka handle all the asynchrony/concurrency.

So even though Akka is a concurrency framework (using actors), and even though Camel is about integration, I have to ask: Can't Akka solve everything that Camel does? In ther words: What use cases still exist to use Camel over Akka?

1
Why the downvote without an explanation? This is not a dupe, shows research effort (in the sense that I thought out an exact use case/scenario), is absolutely code/programming related, and doesn't violate anything with SSCCE! Mayhaps a disgruntled Camel committer?smeeb
Akka is a toolkit and runtime for building highly concurrent,distributed, and resilient message-driven applications on the JVM. Camel is a EIP. Does Akka implement EIP patterns? While Akka can do what Camel does the focus of these two packages are completely different.Namphibian
Yeah downvoting without a explanation is also a pet peeve of mine.Namphibian

1 Answers

27
votes

Akka and Camel are two different beasts (besides one is a mountain and one is an animal).

You mention it yourself: Akka is a tool to implement the reactor pattern, i.e. a message based concurrency engine for potentially distributed systems.

Camel is a DSL/framwork to implement Enterprise Integration Patterns.

There are a lot of things that would be pretty though in Akka, that is easy in Camel. Transactions for sure. Then all the logic various transport logic and options, as Akka does not have an abstraction for an integration message. Then there are well developed EIPs that are great in Camel, the multicast, splitting, aggregation, XML/JSON handling, text-file parsing, HL7, to mention a only a few. Of course, you can do it all in pure java/scala, but that's not the point. The point is to be able to describe the integration using a DSL, not to implement the underlying logic once again.

Non the less, Akka TOGETHER with Camel is pretty interesting. Especially using Scala. Then you have EIP on top of the actor semantics, which is pretty powerful in the right arena.

Example from akka.io

import akka.actor.Actor
import akka.camel.{ Producer, Oneway }
import akka.actor.{ ActorSystem, Props }

class Orders extends Actor with Producer with Oneway {
  def endpointUri = "jms:queue:Orders"
}

val sys = ActorSystem("some-system")
val orders = sys.actorOf(Props[Orders])

orders ! <order amount="100" currency="PLN" itemId="12345"/>

A full sample/tutorial can be found at typesafe.