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.
I see basically two ways to organize this interaction.
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?
You can use any approach. In second approach you need to be sure that ServiceA is accessible from ServiceB. If it is accessible, then actually I am not able to guess reason why we need altogether separate service i.e. ServiceC for co-ordination. ServiceB can directly subscribe to events in ServiceA. If you are planning to use some kind of polling then would suggest to have a look at http://resthooks.org/ which will reduce network calls as well as improve server performance.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句