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. Select the configured target from the Target Configuration ID drop-down list and add more targets to the list by clicking the Add button.
Figure 1: Round Robin Load Balancing Strategy
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 Add button; 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.
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 on the response destination.
When used with Fiorano ESB, JMS Replier micro service can be used to act as the JMS targets.