Managing parallel microservice requests
A method, computer program product, and system for managing parallel microservices are provided. The method may include identifying information pertaining to each of a plurality of target microservices to be invoked by an issuer microservice, a predefined condition associated with the plurality of target microservices, and an action to be executed by the issuer microservice in response to the predefined condition being satisfied. The method may also include sending a first request to available target microservices of the plurality of target microservices based on the information pertaining to the respective available target microservices. The method may also include, in response to receiving a response to the first request from an available target microservice of the available target microservices, determining whether the predefined condition is satisfied, and in response to determining that the predefined condition is satisfied, causing the action to be executed by the issuer microservice.
1. A computer-implemented method comprising:
identifying, by one or more processors, information pertaining to respective target microservices of a plurality of target microservices to be invoked by an issuer microservice;
sending, by one or more processors, a first request to available target micro services of the plurality of target microservices based, at least in part, on the information pertaining to the respective available target microservices;
in response to receiving a response to the first request from an available target microservice of the available target microservices, determining, by one or more processors, whether a predefined condition is satisfied; and
in response to determining that the predefined condition is satisfied, sending, by one or more processors, a second request in parallel to respective unresponsive available target microservices of the available target microservices, wherein the second request requests the unresponsive available target microservices to cancel the first request.
2. The computer-implemented method of claim 1 , wherein the first request is sent to the available target microservices respectively in parallel.
3. The computer-implemented method of claim 1 , wherein the predefined condition is that the response satisfies a predefined requirement.
4. The computer-implemented method of claim 1 , wherein the predefined condition is that a number of responses from the plurality of target microservices that satisfy a predefined requirement reaches a predefined number.
5. The computer-implemented method of claim 1 , further comprising:
determining, by one or more processors, whether remaining target microservices of the plurality of target microservices, excluding the available target microservices, are available, and
in response to at least one of the remaining target microservices being available, sending, by one or more processors, the first request to the at least one of the remaining target microservices.
6. The computer-implemented method of claim 1 , wherein one or more actions to be taken in response to the predefined condition being satisfied are configurable and maintained by a storage.
7. The computer-implemented method of claim 1 , further comprising:
in response to determining that the predefined condition is unsatisfied, waiting, by one or more processors, for a next response from another available target microservice of the available target microservices.
8. A computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to perform operations including:
identifying information pertaining to respective target microservices of a plurality of target microservices to be invoked by an issuer microservice;
sending a first request to available target microservices of the plurality of target microservices based, at least in part, on the information pertaining to the respective available target microservices;
in response to receiving a response to the first request from an available target microservice of the available target microservices, determining whether a predefined condition is satisfied; and
in response to determining that the predefined condition is satisfied, sending a second request in parallel to respective unresponsive available target microservices of the available target microservices, wherein the second request requests the unresponsive available target microservices to cancel the first request.
9. The computer program product of claim 8 , wherein the first request is sent to the available target microservices respectively in parallel.
10. The computer program product of claim 8 , wherein the predefined condition is that the response satisfies a predefined requirement.
11. The computer program product of claim 8 , wherein the predefined condition is that a number of responses from the plurality of target microservices that satisfy a predefined requirement reaches a predefined number.
12. The computer program product of claim 8 , the operations further including:
determining whether remaining target microservices of the plurality of target microservices, excluding the available target microservices, are available, and
in response to at least one of the remaining target microservices being available, sending the first request to the at least one of the remaining target microservices.
13. The computer program product of claim 8 , wherein one or more actions to be taken in response to the predefined condition being satisfied are configurable and maintained by a storage.
14. The computer program product of claim 8 , the operations further including:
in response to determining that the predefined condition is unsatisfied, waiting for a next response from another available target microservice of the available target microservices.
15. A computer system comprising:
a processing unit; and
a memory coupled to the processing unit and storing instructions thereon, the instructions, when executed by the processing unit, performing operations including:
identifying information pertaining to respective target microservices of a plurality of target microservices to be invoked by an issuer microservice;
sending a first request to available target microservices of the plurality of target microservices based, at least in part, on the information pertaining to the respective available target microservices;
in response to receiving a response to the first request from an available target microservice of the available target microservices, determining whether a predefined condition is satisfied; and
in response to determining that the predefined condition is satisfied, sending a second request in parallel to respective unresponsive available target microservices of the available target microservices, wherein the second request requests the unresponsive available target microservices to cancel the first request.
16. The computer system of claim 15 , wherein the first request is sent to the available target microservices respectively in parallel.
17. The computer system of claim 15 , wherein the predefined condition is that the response satisfies a predefined requirement.
18. The computer system of claim 15 , wherein the predefined condition is that a number of responses from the plurality of target microservices that satisfy a predefined requirement reaches a predefined number.
19. The computer system of claim 15 , wherein one or more actions to be taken in response to the predefined condition being satisfied are configurable and maintained by a storage.
20. The computer system of claim 15 , the operations further including:
in response to determining that the predefined condition is unsatisfied, waiting for a next response from another available target microservice of the available target microservices.