What is the best way to coordinate the interaction of two restful services using a third one?

Rafael Regis

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.

  1. ServiceC as the ResourceA direct intermediator

    • ServiceC gets the full ResourceA from ServiceA
    • ServiceC post it to ServiceB
    • ServiceB returns ResourceB
  2. 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?

Bhisham Balani

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

What is the best way to communicate between two windows in Qt

来自分类Dev

What is the best way to call async methods using reactiveui + throttle

来自分类Dev

What is the best way to iterate an nested object in rails

来自分类Dev

What is the best way to parse binary protocols with Rust

来自分类Dev

What is the best way to wait for an animation to finish in MVVM?

来自分类Dev

Retrieve & Update functions for summing two arrays in a third one

来自分类Dev

Best way to associate two strings of text in VB.NET

来自分类Dev

What's the best way to do math with CGFloats in swift?

来自分类Dev

libGDX What's the best way to render a large background image?

来自分类Dev

What is the best way to decouple a caller of spawn from the spawned procedure?

来自分类Dev

What's the best way to store Phone number in Django models

来自分类Dev

What is the best way to store very large binary numbers in JavaScript?

来自分类Dev

What is the best way to wait for the completion of all workers in a thread pool?

来自分类Dev

What is the best way for a class to listen to events in an object it has instantiated? (Swift)

来自分类Dev

What's the best way to capture a digital signature in Rails 4?

来自分类Dev

What's the best way to perform a parallel copy on Unix?

来自分类Dev

HTTP two-way proxy using Twisted

来自分类Dev

Best way to populate data on DOM using jQuery and Node

来自分类Dev

Merging two string rows into one using Pandas

来自分类Dev

单元测试球衣Restful Services

来自分类Dev

Restful Spring Services中的会话范围

来自分类Dev

Install TomEE Plus in NetBeans 8.0 for RESTful Services

来自分类Dev

Restful Web Services中的异步多线程

来自分类Dev

Fastest way to find the third largest of five given numbers without using array or loops?

来自分类Dev

Adding custom properties to Express app and req. What's the best way?

来自分类Dev

What is the current best way to wrap console.log() that will preserve line numbers?

来自分类Dev

What's the best way to handle Culture in a .NET MVC/WebApi app which uses async?

来自分类Dev

Spring Boot与RESTful Web Services的Apache CXF相比?

来自分类Dev

Alfresco RESTful Services创建自定义元数据

Related 相关文章

  1. 1

    What is the best way to communicate between two windows in Qt

  2. 2

    What is the best way to call async methods using reactiveui + throttle

  3. 3

    What is the best way to iterate an nested object in rails

  4. 4

    What is the best way to parse binary protocols with Rust

  5. 5

    What is the best way to wait for an animation to finish in MVVM?

  6. 6

    Retrieve & Update functions for summing two arrays in a third one

  7. 7

    Best way to associate two strings of text in VB.NET

  8. 8

    What's the best way to do math with CGFloats in swift?

  9. 9

    libGDX What's the best way to render a large background image?

  10. 10

    What is the best way to decouple a caller of spawn from the spawned procedure?

  11. 11

    What's the best way to store Phone number in Django models

  12. 12

    What is the best way to store very large binary numbers in JavaScript?

  13. 13

    What is the best way to wait for the completion of all workers in a thread pool?

  14. 14

    What is the best way for a class to listen to events in an object it has instantiated? (Swift)

  15. 15

    What's the best way to capture a digital signature in Rails 4?

  16. 16

    What's the best way to perform a parallel copy on Unix?

  17. 17

    HTTP two-way proxy using Twisted

  18. 18

    Best way to populate data on DOM using jQuery and Node

  19. 19

    Merging two string rows into one using Pandas

  20. 20

    单元测试球衣Restful Services

  21. 21

    Restful Spring Services中的会话范围

  22. 22

    Install TomEE Plus in NetBeans 8.0 for RESTful Services

  23. 23

    Restful Web Services中的异步多线程

  24. 24

    Fastest way to find the third largest of five given numbers without using array or loops?

  25. 25

    Adding custom properties to Express app and req. What's the best way?

  26. 26

    What is the current best way to wrap console.log() that will preserve line numbers?

  27. 27

    What's the best way to handle Culture in a .NET MVC/WebApi app which uses async?

  28. 28

    Spring Boot与RESTful Web Services的Apache CXF相比?

  29. 29

    Alfresco RESTful Services创建自定义元数据

热门标签

归档