简体   繁体   English

Apache Camel-路由起始层

[英]Apache Camel - route starting layer

Suppose I've got an application based on Spring MVC with the following layers: - front end (jsp) - controller - manager - service - data access 假设我有一个基于Spring MVC的应用程序,具有以下几层:-前端(jsp)-控制器-管理器-服务-数据访问

I've got the following problem: some of the views require data from different sources (web services and internal DB) and after sourcing need to be aggregated. 我遇到了以下问题:一些视图需要来自不同来源(Web服务和内部DB)的数据,并且在采购之后需要进行汇总。 I'd like to make it in Camel, but the question is - which layer should 'fire' the route. 我想用骆驼制作它,但是问题是-哪一层应该“激发”路线。 In other words - I'd like to know the flow: first the front end takes us to one of the controller methods. 换句话说-我想知道流程:首先,前端将我们带到一种控制器方法。 But is it the place to start the camel route from? 但这是从那里开始骆驼路线的地方吗?

I think there is a confusion between starting a Route and starting an Exchange . 我认为启动Route和启动Exchange之间存在混淆。

The route will be started as soon as CamelContext will be started by the corresponding ApplicationContext . 一旦CamelContext由相应的ApplicationContext启动,路由就会启动。 The Exchange on the particular route can be started using Injected ProducerTemplate eg: http://camel.apache.org/pojo-producing.html 可以使用Injected ProducerTemplate开始特定路径上的Exchange ,例如: http : //camel.apache.org/pojo-production.html

The best place to aggregate the content from the different sources is a Camel Route itself. 汇总来自不同来源的内容的最佳位置是Camel Route本身。

I would create a Service Facade and initiate Camel Exchange, using ProducerTemplate, from there, as suggested here: https://camel.apache.org/hiding-middleware.html 我将创建一个Service Facade并使用ProducerTemplate从那里启动Camel Exchange,如此处建议的那样: https : //camel.apache.org/hiding-middleware.html

All the Data Sources should be accessed in the Camel route, subsequently, Camel Route will apply the corresponding Enterprise Integration Pattern to enrich/aggregate/transform the content. 所有数据源都应在骆驼路线中访问,随后,骆驼路线将应用相应的企业集成模式来丰富/聚合/转换内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM