You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hasikada <ad...@gmail.com> on 2015/06/29 15:01:54 UTC

Multiple Camel contexts and request to multiple replies communication pattern (multicast)

Hello,

I work on the ESB (entiprise service bus) project based on Apache Camel
running on Apache Karaf. The ESB provides several different services, Each
service provides REST API (e.g TestRest), service routes (e.g TestService)
and service beans (e.g TestBean). The service classs contains one CXFRS
route that delivers a REST request to an appropriate service route. Each
service is implemented as OSGI bundle. But currently the bundles are not
independent on each other. There is only one blueprint configuration for all
beans from all service bundles with only one Camel context. I plan to
refactor to situation where each service bundle has own blueprint and Camel
context. It raises question how to communicate between multiple independent
Camel Contexts. The JMS would be a possibility, but I need one request to
multiple replies pattern.

For example, I implemented the integrity check service (CheckService). The
service requests an integrity check on the other services (e.g MapService,
MediaService, NetworkService, etc).
	
	// CheckService

from("cxfrs:bean:checkServer?resourceClass=CheckService&bindingStyle=SimpleConsumer")
            .recipientList(simple("direct:${header.operationName}"));

	from("direct:checkServices")
	    .multicast().aggregationStrategy(new ListAggregator<ServiceResponse>())
	    .to(
	        "direct:checkMapService",
	        "direct:checkMediaService",
	        "direct:checkNetworkService
	        )
	    .end();

So, when an ESB client sends a REST request, CheckService needs to call each
integrity check service route over all known service bundles.

It would be nice if CheckService provides well known queue for the intergity
check requests. Any service bundle with integrity check implementation would
consumes request from the queue.

	// Check Service
	from("direct:checkServices")
	    ....
	    .to("jms.integrityCheckRequests");

	// MapService
	from("jms:integrityCheckRequests").to("direct:checkMapService");
	
	// MediaService
	from("jms:integrityCheckRequests").to("direct:checkMediaService");

A ESB client sends the REST request for integrity check and expects the
aggregated check service result in the response.
It raises another question how to aggregate responses in
'direct:checkServices' route. Using request-reply messaging (InOut) in JMS
is not probably solution. Create another aggregation queue for responses
from services is not solution also due to asynchronous nature, as a client
expects result in REST request response.

Maybe the invert solution would work. Each service bundle registers its JMS
endpoint for integrity check to common database. The Check service reads
endpoints from the database and invoke them in request-reply manner.

	from("direct:checkServices")
	    ....
	    .recipientList(header("recipients")).aggregationStrategy(new
ListAggregator<ServiceResponse>());

Please, do you have any better idea?

Adam




--
View this message in context: http://camel.465427.n5.nabble.com/Multiple-Camel-contexts-and-request-to-multiple-replies-communication-pattern-multicast-tp5768668.html
Sent from the Camel - Users mailing list archive at Nabble.com.