Question

Suppose I've got an application based on Spring MVC with the following layers: - front end (jsp) - controller - manager - service - data access

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. 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?

Was it helpful?

Solution

I think there is a confusion between starting a Route and starting an Exchange.

The route will be started as soon as CamelContext will be started by the corresponding ApplicationContext. The Exchange on the particular route can be started using Injected ProducerTemplate e.g.: http://camel.apache.org/pojo-producing.html

The best place to aggregate the content from the different sources is a Camel Route itself.

I would create a Service Facade and initiate Camel Exchange, using ProducerTemplate, from there, as suggested here: 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top