何时使用 Spring Integration 与 Camel?
作为一名经验丰富的 Spring 用户,我认为 Spring Integration 在最近需要一些(JMS)消息传递功能的项目中最有意义(更多详细信息)。使用 Spring Integration 几天后,考虑到必须配置的通道数量来实现一些请求-响应(侦听不同的 JMS 队列)通信,仍然感觉配置开销很大。
因此,我一直在寻找一些背景信息,Camel 与 Spring Integration 有何不同,但似乎信息非常多余,我发现:
- http://java.dzone.com/articles/spring-integration-and-apache (在 Spring Integration 与实现真实世界集成场景之间进行非常中立的比较. Camel,2009 年 12 月起)
- http://hillert.blogspot.com/ 2009/10/apache-camel-alternatives.html(Camel 与其他解决方案的比较,2009 年 10 月)
- http://raibledesigns.com/rd/entry/take_apache_camel_for_a(Matt Raible,2008 年 10 月)
问题是:您在使用一个堆栈而不是另一个堆栈时获得了哪些经验?如果 Spring Integration 缺乏支持,您会在哪些场景下推荐 Camel?您在哪里看到每个的优点和缺点?任何来自实际项目的建议都将受到高度赞赏。
As a seasoned Spring user I was assuming that Spring Integration would make the most sense in a recent project requiring some (JMS) messaging capabilities (more details). After some days working with Spring Integration it still feels like a lot of configuration overhead given the amount of channels you have to configure to bring some request-response (listening on different JMS queues) communications in place.
Therefore I was looking for some background information how Camel is different from Spring Integration, but it seems like information out there are pretty spare, I found:
- http://java.dzone.com/articles/spring-integration-and-apache (Very neutral comparison between implementing a real-world integration scenario in Spring Integration vs. Camel, from December 2009)
- http://hillert.blogspot.com/2009/10/apache-camel-alternatives.html (Comparing Camel with other solutions, October 2009)
- http://raibledesigns.com/rd/entry/taking_apache_camel_for_a (Matt Raible, October 2008)
Question is: what experiences did you make on using the one stack over the other? In which scenarios would you recommend Camel were Spring Integration lacks support? Where do you see pros and cons of each? Any advise from real-world projects are highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
我们选择 Camel 而不是 Spring-Integration,因为流畅的 API 非常好。我们实际在Spring项目中使用它,并使用Spring来配置一部分。编程 API 很清晰,并且有大量合理的组件。
我们进行了一场小规模的枪战,基本上当时我们的要求是骆驼赢了。我们主要使用它来将内部数据文件传输到外部各方或从外部各方传输内部数据文件,这通常需要格式转换,使用 ftp/sftp/... 发送它或将其附加到电子邮件中并将其发送出去。
我们发现编辑-编译-调试周期缩短了。使用 groovy 来尝试设置路线还有额外的好处。
Spring-Integration也是一个很棒的产品,我确信它也能满足我们的需求。
We choose Camel over Spring-Integration because the fluent API is really nice. We actually use it in Spring projects and use Spring to configure part of it. The programming API's are clear and there is a large set of sensible components.
We did a small scale shootout and basically at that time for our requirement Camel won. We use it mainly to transfer internal datafiles to/from external parties which usually requires format conversions sending it using ftp/sftp/... or attaching it to an email and sending it out.
We found the edit-compile-debug cycle reduced. Using groovy to experiment setting up routes are added bonuses.
Spring-Integration is a great product too, and I am quite sure it would satisfy our needs too.
如果您已经有了一个 Spring 项目,并且只需使用文件、FTP、JMS、JDBC 等添加一些“基本”集成,我只推荐 Spring Integration。
Apache Camel 有两个主要优点:
由于 Apache Camel 与 Spring 的集成非常好,我什至会在大多数 Spring 项目中使用它来代替 Spring Integration。
如果您需要更多详细信息,可以在我的博客文章中阅读我的经验:选择过多:使用哪种集成框架 – Spring Integration、Mule ESB 还是 Apache Camel?
I only recommend Spring Integration if you already have got a Spring project and you have just to add some "basic" integration using File, FTP, JMS, JDBC, and so on.
Apache Camel has two main advantages:
Because Apache Camel has very good integration with Spring, I would even use it instead of Spring Integration in most Spring projects.
If you need more details, you can read my experiences in my blog post: Spoilt for Choice: Which Integration Framework to use – Spring Integration, Mule ESB or Apache Camel?
我最近进行了 Camel 与 Spring 集成对比,目的是集成 Apache Kafka。尽管我是一名狂热的 Spring 开发人员,但我遗憾地发现我对 Spring 不断增长的项目堆栈的怀疑得到了证实:Spring 作为 IOC 容器非常棒,可以充当其他框架的粘合剂,但它未能提供可行的替代方案 那些框架。可能会有例外,即与 MVC 相关的一切,Spring 的起源和它的出色工作,但其他在容器功能之上提供新功能的尝试由于三个原因而失败SI Kafka 用例证实了所有这些:
现在,回到我的点球大战的结果:最重要的是,Camels 的端点之间的路线的总体概念给我留下了深刻的印象。 Kafka 与这个概念无缝集成,三行配置足以让一切正常运行。 项目团队提供的充足文档以及Stackoverflow 上有很多问题。最后但并非最不重要的一点是,与 Spring 的全面集成可以满足所有愿望。
与 SI 相反,Kafka 集成的文档相当密集并且仍然未能清楚地解释如何集成Kafka。 Kafka 的集成被压入到 SI 的做事方式中,这增加了额外的复杂性。其他文档(例如 Stackoverflow 上的文档)也不像 Camel 那样丰富且没有帮助。
我的结论:cobbler 坚持自己的职业——使用 Spring 作为容器,使用 Camel 作为系统集成框架。
I have recently conducted a Camel vs Spring Integration shoot-out with the aim to integrate Apache Kafka. Despite being an avid Spring developer, I sadly found my suspicion with Spring's ever-growing Project stack confirmed: Spring is awesome as IOC-Container to serve as glue for other framework, but it fails at providing viable alternatives to those frameworks. There might be exceptions to this, namely everything to do with MVC, where Spring came from and where it does a great job, but other attempts to provide new functionality on top of container features fall short for three reasons and the SI Kafka use case confirms all of them:
Now, back to the results of my shoot-out: most importantly I am impressed by Camels overall concept of routes between endpoints. Kafka seamlessly integrates with this concept and three lines of configuration are enough to get everything up-and-running. Problems encountered during the process are neatly addressed by ample documentation from the project team as well as a lot of questions on Stackoverflow. Last but not least, there is a comprehensive integration into Spring that leaves no wishes unfulfilled.
With SI on the contrary, the documentation for the Kafka integration is quite intense and still fails to explain clearly how to integrate Kafka. The integration of Kafka is pressed into the SI-way of doing things, which adds extra complexity. Other documentation, e.g. on Stackoverflow is also less plentiful and less helpful than for Camel.
My conclusion: cobbler stick to your trade - use Spring as a container and Camel as system integration framework.
这实际上取决于你想做什么。如果您需要扩展某些内容来构建自己的消息传递解决方案,Spring Integration 具有更好的编程模型。如果您需要无需自定义代码即可支持多种协议的东西,Camel 优于 Spring Integration。
进行小规模的枪战是一个非常好的主意,只要确保你正在尝试做你通常在项目中做的事情。
--免责声明:我是 Spring Integration 提交者
It really depends on what you want to do. If you need to extend something to build your own messaging solution Spring Integration has the better programming model. If you need something that supports many protocols without custom code, Camel is ahead of Spring Integration.
Having a small scale shootout is a very good idea, just make sure you're trying to do the type of things that you'd typically be doing in the project.
--disclaimer: I'm a Spring Integration committer
我见过的大多数 Camel 和 SI 的比较都没有考虑以下因素:
1.) Spring Boot 对 Spring Integration 开发人员生产力的影响
2.) Spring XD 对 Spring Integration 的影响无需代码编译即可使用的应用程序 - 当您希望扩展 Spring XD 时,Spring XD 源和接收器也只是 Spring Integration 通道适配器。
3.) Spring XD 的作用是将 Spring Integration、Spring Batch、Spring Data (+Hadoop!) 统一在一个堆栈中,有效地为 Spring Integration 带来批处理和流处理、HDFS/Apache Hadoop 支持等。
4.) 即将发布的 Spring Integration 4.0 Java DSL 的效果 https://github.com/spring-projects/spring-integration-extensions/wiki/Spring-Integration-Java-DSL-Reference
供您考虑,
/Pieter(免责声明,我在 Pivotal 工作)
Most comparisons of Camel and SI that I've seen don't take the following into account:
1.) The effect that Spring Boot has had on developer productivity for Spring Integration
2.) The effect of Spring XD has had on making Spring Integration applications available with no code compilation - also Spring XD sources and sinks are simply Spring Integration channel adapters, when you're looking to extend Spring XD.
3.) The effect of Spring XD has had on making unifying Spring Integration, Spring Batch, Spring Data (+Hadoop!) in one stack, effectively bringing batch and stream processing, HDFS/Apache Hadoop support, and much more to Spring Integration.
4.) The effect of the soon-to-be-released Spring Integration 4.0 Java DSL https://github.com/spring-projects/spring-integration-extensions/wiki/Spring-Integration-Java-DSL-Reference
For your consideration,
/Pieter (disclaimer I work at Pivotal)
我们正在为我们的应用程序使用 Spring Integration,现在考虑迁移到 Apache Camel,因为我们在使用 Spring Integration 框架时遇到了很多问题。这里有几个问题。
Spring 提供的 CachingConnectionFactory 在 IBM MQ 中打开了 1000 个空闲连接,并且不能保证这些连接会被重用。而且这些连接仍然会永远保持打开状态,这会给 MQ 端带来麻烦。必须每周在较低环境中重新启动应用程序才能刷新连接。 Apache Camel 还提供缓存,并且连接似乎会根据负载而增加/减少。
Spring 不提供 QoS 参数的映射器。即使启用 QoS,交付模式和过期/生存时间属性也会丢失(我将为此提出 JIRA 问题)。 Apache Camel 处理此问题,并将 QoS 参数发送到上游应用程序而不丢弃它。
我现在正在研究使用 Apache Camel 处理异常和事务的问题,而 Spring 似乎可以通过 AOP 更好地处理这些问题。
We are using Spring Integration for our application and now considering to move to Apache Camel as we encountered lots of issues with Spring Integration framework. Here are couple of issues.
The CachingConnectionFactory which Spring provides opens 1000's of idle connections in IBM MQ and there is no guarantee that these connections are reused. And still these connections will stay open forever which creates troubles on the MQ side. Had to restart the application every week in lower environments just to refresh the connections. Apache Camel also provides Caching and the connections seems to go up/down based on the load.
Spring doesn't provide mappers for QoS parameters. Even if you enable QoS, the delivery mode and expiration/timetolive properties will get lost (I am going to raise a JIRA issue for this). Apache Camel handles this and QoS parameters are sent to upstream applications and not dropping it.
I am right now working on issues with handling the exceptions and transactions with Apache Camel which Spring seemed to handle better with AOP.
Apache Camel 是一个非常好的框架,也非常完整。但如果你的应用程序使用Spring,我个人的建议是使用Spring Integration。
Spring Integration是Spring-Source生态系统的集成EIP投诉框架。它与生态系统有很好的集成:Spring boot、Batch、XD;从 Spring Framework 4 开始,甚至核心也使用相同的抽象。框架中移动了一些消息抽象,这证明了 Spring Integration 的基本消息抽象非常强大。现在,Spring 框架使用 Spring Web 的消息抽象、Web 套接字支持。
在使用 Spring 集成的 Spring 应用程序中,使用 Apache Camel 的另一件好事是,通过 Spring 集成,您只能使用一个应用程序上下文。请记住,Camel 上下文是 Spring 上下文。如果您有机会使用新的 Spring 版本,我建议使用 Spring Integration Java DSL 进行配置。我在我的新项目中使用它,感觉更具可读性和清晰性。我希望这篇反思能够对您的评估有所帮助。
Apache Camel is a very good framework and very complete too. But if your application uses spring, my personal advice is to use Spring Integration.
Spring Integration is the integration EIP complaint framework of Spring-Source ecosystem. It has excellent integration with the ecosystem: Spring boot, Batch, XD; even the core uses same abstraction starting from Spring Framework 4. Some of the messaging abstraction were moved in the framework, as proof that the basic messaging abstraction of Spring Integration is very strong. Now Spring framework for instance use the messaging abstraction for Spring Web, web socket support.
Another good thing in a Spring application with Spring integration respect to use Apache Camel is that with Spring integration, you can use only one Application Context. Remember that the Camel Context is a Spring context. if you have the chance of use a new Spring version, I suggest to use Spring Integration Java DSL for configuration. I use it on my new projects, and it feels more readable and clear. I hope that this reflection can help you for the your evaluations.
事实上,我想说FTP的潜伏期已经结束了。您可以在 SI 论坛/JIRA 上进行简单搜索,看看实现了哪些新功能以及修复了哪些错误。从各种讨论来看,它似乎已经有一些生产用途,所以我建议再看一下,当然也可以通过
http://forum.springsource.org/forumdisplay.php?42-集成
https://jira.springsource.org/browse/INT
干杯
Oleg
免责声明:我是 Spring Integration 提交者
Actually, I would say FTP has graduated its incubation period. You can do a simple search on SI forums/JIRA to see what new features were implemented and bugs that were fixed. From various chatter it seems like there is already some production usage out of it, so I would suggest to give it a second look and of course communicate your concerns to us via
http://forum.springsource.org/forumdisplay.php?42-Integration
https://jira.springsource.org/browse/INT
Cheers
Oleg
Disclaimer: I am Spring Integration committer
使用 Camel 而不是 Spring Integration 的原因之一是当您需要功能更强大的 EIP 集时。 Spring Integration 不提供对 ThreadPool 等事物的抽象。
Camel 确实为此提供了额外的构造,简化了使用并发代码的一些方面:
https: //camel.apache.org/manual/threading-model.html
如果您不需要这类事情,只想连接文件、JMS、FTP 端点等,那么只需使用 Spring Integration。
One reason to use Camel over Spring Integration is when you need a more featureful EIP set. Spring Integration doesn't provide abstractions over things such as ThreadPool.
Camel does provide additional constructs for this simplifying some of the aspects of working with concurrent code:
https://camel.apache.org/manual/threading-model.html
If you have no need for this sort of thing and just want to connect file, JMS, FTP endpoints, etc. then just use Spring Integration.
Camel 充当应用程序的中间件,可以在其中执行数据建模、消息值转换和消息编排。
Camel act as middleware for application where one can perform data modeling, transformation of message values and choreography of messages.
如果您当前的应用程序位于 Spring 中并且需要 EIP 的 Spring Integration 支持的功能,那么 Spring Integration 是最佳选择,否则需要更多第三方支持/协议/文件格式等
If your current application is in Spring and require features which are supported by Spring Integration of EIP then Spring Integration is the best option else require more third party supports/protocols/file formats etc