2

Having several backend modules exposing a REST API, one of the module needs to call other modules through their API and have an immediate response.

A solution is to directly call the REST API from this 'top' module. The problem is that it creates coupling, does not support scaling or failover natively.

A kind of bus (JMS, ESB) permits to decouple the modules by avoiding the need of endpoints known by the modules. They only 'talk' to the bus.

What would you use to enable fast response through the bus (another constraint is you don't have multicast as it could be deployed in the cloud)?

Also is it reasonable to still rely on the REST api or would a JMS listener be better? I thought about JMS, Camel, ESB's. Do you know about companies using such architecture?

ps: a module could be a java war running on a tomcat instance for example.

unludo
  • 4,912
  • 7
  • 47
  • 71

1 Answers1

3

If your top module "knows" to call the other modules, then yes you have a coupling, which could be undesirable. If instead your top module is directed to the other modules through links, forms and/or redirects from the responses from the middle module, then you have the same amount of coupling that a JMS solution would give you.

When you need scalability and failover (not before), add a caching reverse proxy such as an F5 or Varnish. This will be more scalable and resilient than any JMS based solution.

Udpate

In situations where you want to aggregate and/or transform the responses from the other modules, you're simply creating a composed service. The top module calls the middle module, which makes one or more calls to the back-end modules, composes the results and sends the appropriate response. Using a HTTP cache in between each hop (i.e. Top -> Varnish -> Middle -> Varnish -> Backend) is a much easier and more efficient way to cache the data, compared to a bespoke JMS based solution.

Tom Howard
  • 6,516
  • 35
  • 58
  • thanks for this interesting answer. Sometimes though you want to aggregate information to present it in a 'better shape' and to cache it for yor web app or whatever client. In this case modules need to get information from others. I am also interested in this use case. – unludo Feb 29 '12 at 10:49