Apache Camel 是否会替代或补充使用 Spring Boot 创建微服务?

问题描述 投票:0回答:3

我已经使用 Spring 微服务工作了一段时间,但没有遇到过 Apache Camel 作为构建微服务的工具。我不清楚——Apache Camel 是使用 Spring Boot 创建微服务的替代品,还是添加了使用 Spring Boot 开发此类服务的功能/快捷方式?使用 Spring Boot 创建微服务已经相当简单,因此很难想象 Apache Camel 会添加什么,但这就是我问题的本质。

spring spring-boot apache-camel microservices
3个回答
2
投票

Apache Camel 与微服务无关。

它是企业集成模式的实现:https://www.enterpriseintegrationpatterns.com/

Apache Camel 为 Gregor Hohpe 和 Bobby Woolf 书中的大多数模式提供了实现。加上各种入站和出站端点,可与文件系统、FTP、HTTP、消息传递、Facebook 等系统集成。

在网站上查找更多信息:https://camel.apache.org/

有一个 Spring Boot Starter 项目可以在 Spring Boot 应用程序中运行 Camel: https://camel.apache.org/camel-spring-boot/4.0.x/index.html


1
投票

Apache Camel 会添加什么,这就是我问题的本质

为了声明基于 REST 的微服务,Camel 的 REST DSL 提供了一个用于声明微服务的流畅 API。举个例子:

rest("/books").produces("application/json")
    .get().outType(Book[].class)
        .to("bean:bookService?method=getBooks(${header.bookCategory})")

应该一看就知道,请求路径 /books 会得到一个 Book List,只要你发送一个名为 bookCategory 的请求参数。这被映射到一个名为 bookService 的 POJO bean。


0
投票

Spring Boot 是一个简化应用程序打包和启动的框架,而 Spring 是实际的框架,它具有用于执行各种任务的库。 从技术上讲,我们也可以使用Camel来构建微服务,并且camel的许多方面都依赖于Spring。如果您预见到许多与集成相关的功能,例如发送电子邮件或与其他系统通信,您也可以使用六角形架构。

© www.soinside.com 2019 - 2024. All rights reserved.