应该如何打包/部署 ESB?
我正试图围绕 Apache Camel,它似乎是一个轻量级 ESB.如果我正确理解 Camel/ESB,那么您可以将 Camel Route 视为节点和边的图.每个节点都是路由上的一个端点(可以消费/产生消息).每条边都是两个不同端点(1 个生产者和 1 个消费者)之间的路由.
I am trying to wrap my head around Apache Camel, which appears to be a lightweight ESB. If I understand Camel/ESBs correctly, then you can think of a Camel Route as a graph of nodes and edges. Each node is an endpoint on the route (can consume/produce messages). Each edge is a route between two different endpoints (1 producer and 1 consumer).
假设这是正确的,我有一个实际问题:最佳实践对部署应用程序的 ESB/Camel Route 有什么要求?我应该将它打包成自己的 JAR,还是值得成为自己的 EAR,里面装满了 EJB、Web 服务和其他 JAR?
Assuming that's correct, I have a practical question: what do best practices dictate about deploying your application's ESB/Camel Route? Should I package it up as its own JAR, or is it worthy of being its own EAR full of EJBs, Web Services and other JARs?
我想我在问应该如何部署/架构 Camel Route 或 ESB,例如:
I guess I'm asking how a Camel Route or ESB should be deployed/architected, like:
my-esb.ear/
ejb1.jar/
MyEJB_1.class
ejb2.jar/
MyEJB_2.class
webservice.war/
MyWebService.class
或者……
my-esb.jar/
MyEJB_1.class
MyEJB_2.class
MyWebService.class
推荐答案
据我了解,有几种方法可以运行 Camel.
From my understanding there is a couple of ways you can run Camel.
嵌入到 Java 应用程序中:您可以将 Camel 嵌入到独立的 Java 应用程序中.在这种情况下,您将在您的应用程序中启动一个 Camel 上下文,它将启动路由等.当您的应用程序需要与服务等进行通信时,这非常有用.为此,您需要为组件部署 Camel 和第三方 jars类路径.
Embedded in a Java Application: You can embed Camel in a stand alone Java application. In this scenario you would start a Camel Context inside your application which will start the routes etc. This is great when your application needs to communicate with services etc. For this to work you would need to deploy the Camel and third party jars for components to the classpath.
嵌入到 Web 应用程序中:正如人们已经指出的那样,这似乎是一种流行的选择.Camel jars 和第三方 jars 被包装在一个 WAR 文件中,并且基本上部署到一个 Web 容器(例如 Tomcat)来托管 Camel 服务.
Embedded in a Web Application: As people has already pointed out this seems the a popular option. The Camel jars and third party jars are wrapped in a WAR file and essentially deployed to a web container such as Tomcat to host the Camel services.
嵌入到应用服务器中:我读过一些关于如何将 Camel 部署到 JBoss 等应用服务器的文章,我什至读过关于部署到 Glassfish 的人的文章.这似乎与您部署到 Tomcat 的方式非常相似.JBoss 有一些你需要解决的类加载问题,这使得它变得棘手.所以是的,您可以通过 WAR 路由部署到应用程序服务器.
Embedded in a application server: I have read some article on how to deploy Camel to a Application server such as JBoss and I have even read about people deploying to Glassfish. This seems very similar in how you deploy to Tomcat. JBoss has some class loading issues that you would need to address which makes it tricky. So yes you can deploy to a application server by going the WAR route.
部署到 OSGi:您可以相对快速地将 Camel jar 制作成 OSGi 包,然后部署到 OSGi 框架,例如 Apache Felix.将 jar 转换为适当的 OSGi 包然后部署相对简单.这里的一个大问题是某些第三方可能没有 OSGi 兼容的捆绑包供您部署.
Deploy to OSGi: You can make your Camel jar a OSGi bundle relatively quickly and deploy to a OSGi framework such as Apache Felix. It is relatively simple to convert the jar to a proper OSGi bundle and then deploy. The one big problem here is that some third party might not have OSGi compatible bundles for you to deploy.
我个人的偏好是 OSGi 路线.它简单且轻量,允许我将我的骆驼路由托管为持久服务(即 Window 服务、Unix Deamon),占用空间非常小.
My personal preference is the OSGi route. It is easy and lightweight and allows me to host my camel routes as persistent services (i.e. Window service, Unix Deamon) with a very small foot print.
您现在应该意识到 Apache Camel 可以通过多种方式进行部署,您可以自行决定如何部署.我花了一段时间才了解如何部署 Camel,因为我必须使用不同的部署模型才能对它有一个好的感觉.我唯一没有接触过的是部署到应用程序服务器,因为我觉得这些服务器中的大多数都足够重了.
The thing that you should realise now is that Apache Camel can be deployed in several ways and it is really up to you to decide on how you want to do it. It took me a while to understand how to deploy Camel as I had to play with the different deployment models to get a good feel for it. The only one I have not touched was deploying to a Application Server as I felt most of these Servers are heavy enough.
就架构而言,我喜欢将不同的路由/应用程序保存在不同的 jar 中.由于我使用的是 OSGi,因此我希望能够更新特定路由并进行部署,而无需重新部署所有内容.如果您将所有内容部署在一个 jar 中,您将需要重新构建世界并重新部署该 jar.但是,这是个人喜好,您的里程可能会有所不同
As far as architecture is concerned I like to keep my different routes/applications in different jars. Since I am using OSGi I like to be able to update a specific route and deploy it without having to redeploy everything. If you deployed everything in one jar you would need to take down the world rebuild and redeploy the jar. However this is personal preference and your mileage might vary
希望这会有所帮助.
相关文章