Service Call Out
The Service Callout policy allows calling an external service (third party API) from the API flow. Using a Service Callout policy, it is possible to configure an API proxy to make multiple API calls to deliver relevant geolocation data, customer reviews, items from a partner’s retail catalog, and so on. The service can be either an HTTP service or a JMS service. The target(s) to be invoked can be configured using the Targets section.
Configuration
The configuration encapsulates different alternatives for the back end server that is used to perform the required operations. The load balancing strategy allows hosting multiple identical services on different servers or different types of servers. It is possible to load balance between an HTTP service and a JMS service.
Load Balancing Strategy
The two types of Load Balancing strategies are Round Robin and Weighted Round Robin.
Round Robin
This default algorithm forwards a request to each Target Server in the order in which the servers are listed in the Target Configuration ID.
Figure 1: Round Robin Load Balancing Strategy
Select the configured target from the Target Configuration ID drop-down list and add more targets to the list by clicking the Edit icon. Click the OK button after the selection.
By providing a prefix in the Prefix for variables corresponding to parameters, status codes etc text field, one can choose the scope of parameters and headers like status code which should be considered while invoking the selected targets.
Weighted Round Robin
The Weighted Round Robin algorithm enables configuration of proportional traffic loads on Target Servers. It distributes requests to Target Servers following the weight set for them. The targets which are chosen in the Round Robin strategy reflect under Weighted Round Robin where it is possible to set the respective weight values as required. Existing targets can be added by clicking the Edit button (see Figure 1); the newly added targets reflect under the Round Robin strategy.
Figure 2: Weighted Round Robin Load Balancing Strategy
Examples
Using Authorization Services
If an API needs to invoke a third-party service for authorization, the authorization service can be invoked using a service call out. The response from the call out can be parsed using the Assign Variables Policy and the resultant variables can be used to send an error message or go ahead invoking the target service.
Before the call out, the data that needs to be sent to the target service needs to be stored in variables using the Assign Variable Policy. Requests to the target server need to be built using the Build Message Policy.
Using JMS Targets
JMS targets are invoked as a JMS request. Each request to the JMS system is sent with a property RequestorID and a Header JMSCorrelationID. These properties must be retained in the response message sent to the response destination.
When used with Fiorano ESB, JMS Replier microservice can be used to act as the JMS targets.
Refer to the Examples section for a Use Case where this policy has been used.