1

We have few services that are expensive to call. I want to make a rest service that will act as aggregator for other(heavy) rest services, lets say s1 and s2, in order to limit network calls and number of invocations.

The aggregation service should return response then and only then when it got response from all services s1 and s2. Also aggregation service should group requests from its clients, and send them as one request to s1 and s2. It should wait up to N sec before making call to services s1,s2 or wait until it collects Y requests because response can't be delayed too much. What should I use? Spring integration, webflux, reactor, lowlevel core api?

I'm wondering if there is already in one of those implemented this integration pattern (EIP).

I havent tried any solution yet.

Minat
  • 11
  • 2
  • Hi! You should have a look at Apache Camel: https://camel.apache.org/ Also have a look here: https://stackoverflow.com/questions/8845186/what-exactly-is-apache-camel – Philippe Fery Dec 19 '22 at 15:26

1 Answers1

0

We probably would need more info about your requirements, but let's if something what already exists in Spring Integration can answer to some your questions.

So, to group requests from the same client you definitely can simply use an Aggregator EIP implementation: the client id might be used as a correlation key. You decide yourself what is the best release strategy fits your expectations. And indeed in the end this aggregator endpoint would not emit its reply message until it groups (buffers) messages according to expectations.

See more in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#aggregator

Another your request about got response from all services s1 and s2 sounds like a Scatter-Gather solution. See more in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#scatter-gather.

So, you are going to have in your aggregation service 1) aggregator endpoint to group client's messages together and 2) a scatter-gather to distribute request to several services and wait for their replies.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118