Does Akka obsolesce Camel?
Asked Answered
V

1

16

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?

Voyage answered 21/1, 2015 at 18:26 Comment(3)
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?Voyage
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.Scar
Yeah downvoting without a explanation is also a pet peeve of mine.Scar
W
27

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.

Wellknown answered 21/1, 2015 at 20:7 Comment(3)
Thanks @Petter (+1) - I guess that makes sense. I'm still not seeing the forest through the trees in your specific "Akka w/ Camel" example: what's going on in that code? It looks like you're just sending an Order POJO to a JMS queue - can't I just do that in Camel (without Akka), or just with Akka (using a JMS client)? Thanks again!Voyage
Sure, that's a very simple example. Please read the link in the answer for more examples and details. The essence of it is that even akka promotes Camel as an integration layer for Akka based applications.Wellknown
Love the last line of the example! Very elegant use of Scala's XML support.Sall

© 2022 - 2024 — McMap. All rights reserved.