Akka 是否淘汰了 Camel? [英] Does Akka obsolesce Camel?

查看:19
本文介绍了Akka 是否淘汰了 Camel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Akka 的理解是它提供了一个模型,多个独立的线程可以通过这种模型以高度并发的方式相互通信.它使用演员模型",其中每个线程都是有特定工作要做的演员".您可以协调在什么条件下将哪些消息传递给哪些参与者.

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.

我以前使用过 Camel,对我来说,现在 Akka 如此成熟且有据可查,我觉得它有点失去了光彩/实用性.据我了解,Camel 是关于企业集成,即将多个不同的系统集成在一起,通常以某种服务总线方式.

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.

但是想一想:如果我目前使用 Camel 来:

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

  • 轮询 FTP 服务器以获取文件,一旦找到...
  • 将该文件的内容转换为 POJO,然后...
  • 如果 POJO 具有特定状态,则发送电子邮件,或者
  • 在所有其他情况下将 POJO 持久化到数据库中

我可以用 Akka 做同样的事情;我可以为每个步骤(轮询 FTP、转换文件 -> POJO、电子邮件或持久化)设置 1 个 Actor,将它们连接在一起,让 Akka 处理所有异步/并发.

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.

所以即使 Akka 是一个并发框架(使用 Actor),即使 Camel 是关于集成的,我还是要问:Akka 不能解决 Camel 所做的所有事情吗?换句话说:仍然存在哪些使用 Camel 而不是 Akka 的用例?

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?

推荐答案

阿卡和骆驼是两种不同的野兽(另外一种是山,一种是动物).

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

你自己提到过:Akka 是一种实现反应器模式的工具,即用于潜在分布式系统的基于消息的并发引擎.

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 是实现企业集成模式的 DSL/框架.

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

虽然在 Akka 中有很多东西会很漂亮,但在 Camel 中很容易.交易肯定.然后是各种传输逻辑和选项的所有逻辑,因为 Akka 没有集成消息的抽象.然后是在 Camel 中非常出色的开发良好的 EIP,多播、拆分、聚合、XML/JSON 处理、文本文件解析、HL7 等等.当然,你可以在纯 java/scala 中完成这一切,但这不是重点.重点是能够使用 DSL 来描述集成,而不是再次实现底层逻辑.

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.

不过,Akka TOGETHER with Camel 非常有趣.特别是使用 Scala.然后,您在 actor 语义之上拥有 EIP,这在正确的领域非常强大.

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.

来自 akka.io 的示例

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"/>

完整的示例/教程可以在 typesafe 中找到.

这篇关于Akka 是否淘汰了 Camel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆