Does Akka obsolesce Camel?

强颜欢笑 提交于 2020-01-22 17:24:49

问题


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:


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.



来源:https://stackoverflow.com/questions/28074223/does-akka-obsolesce-camel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!