I have 3 restful services (ServiceA, ServiceB and ServiceC) that handle 2 resources (ResourceA and ResourceB). The media type of the resources is application/hal+json.
- ServiceA generates ResourceA;
- ServiceB consumes ResourceA and produces ResourceB;
- ServiceC coordinates the production of ResourceB by getting ResourceA from ServiceA and posting it to ServiceB.
I see basically two ways to organize this interaction.
ServiceC as the ResourceA direct intermediator
- ServiceC gets the full ResourceA from ServiceA
- ServiceC post it to ServiceB
- ServiceB returns ResourceB
ServiceC as the ResourceA indirect intermediator
- ServiceC gets only a link to ResourceA on ServiceA (through the Content Location header on ResourceA creation, for example)
- ServiceC post this link on to ServiceB (using a link rel of the HAL media type)
- ServiceB directly gets the full ResourceA from ServiceA
- ServiceB returns ResourceB
The first approach seems to be the "classic" one while the second one would be cheaper since there is only one full transmission of ResourceA (ServiceA -> ServiceB) instead of two (ServiceA -> ServiceC -> ServiceB). Ideally, the second approach would be the better one for a big enough ResourceA.
Is there any problem in using the second approach? Is this considered a "anti-pattern" or is it not secure/recomendable in some way? Is there a better interaction pattern?