Suppose you wrapped two calls to service A and B as a HystrixCommand . You now have three options:
use .execute() : pure synchronous call. You call the method and continue your program as soon as the result is received. The total execution time of a program is the sum of both calls. The main stream of your program is very linear.
use .queue() : get Future immediately for both commands. Both service calls are made in parallel. Then use .get() to get the results. These calls are blocked until a result is found. Your total lead time is faster than before: your lead time will be the duration of the longest service call. Use this when you want to combine the results of two services. The main thread of your program is still linear, although both calls are made in parallel.
use .subscribe() : immediately get Observable for both commands. Both service calls are made in parallel. Then use .subscribe() to register a callback for the action on the result after it is available. This is very useful if you do not want to combine the results and want to independently respond to the results of service A and B after their arrival. The main thread of your program is not linear, but reactive: the program flow will continue inside the callback for each command.
Hope this helps.
ahus1
source share