The Call mediator is used to send messages out of the ESB to an endpoint. You can invoke services either in blocking or non-blocking manner.
When you invoke a service in non-blocking mode, the underlying worker thread returns without waiting for the response. In blocking mode, the underlying worker thread gets blocked and waits for the response after sending the request to the endpoint. Call mediator in blocking mode is very much similar to the Callout mediator.
In both blocking and non-blocking modes, Call mediator behaves in a synchronous manner. Hence, mediation pauses after the service invocation and resumes from the next mediator in the sequence when the response is received. Call mediator allows you to create your configuration independent from the underlying architecture.
Non-blocking mode of the Call mediator leverages the non-blocking transports for better performance. Therefore, it is recommended to use it in the non-blocking mode as much as possible. However, there are scenarios where you need to use the blocking mode. For example, when you implement a scenario related to JMS transactions, it is vital to use the underlying threads in blocking mode.
In blocking mode, Call mediator uses the
<ESB_HOME>/repository/conf/axis2/axis2_blocking_client.xml file as the Axis2 configuration. For more information about the blocking transport related parameters that can be configured for the Call mediator, see Configuring axis2_blocking_client.xml.
You can obtain the service endpoint for the Call mediator as follows:
- Pick from message-level information
- Pick from a pre-defined endpoint
If you do not specify an endpoint, the Call mediator tries to send the message using the
WSA:TO address of the message. If you specify an endpoint, the Call mediator sends the message based on the specified endpoint.
The endpoint type can be Leaf Endpoint (i.e. Address/WSDL/Default/HTTP) or Group Endpoint (i.e. Failover/Load balance/Recipient list). Group Endpoint is only supported in non-blocking mode.
The Call mediator is a content-unaware mediator.
If the message is to be sent to one or more endpoints, use the following syntax:
endpointreftoken refers to the following:
endpointtoken refers to an anonymous endpoint definition.
Select one of the following options to define the endpoint to which the message should be delivered.
|None||Select this option if you do not want to provide an endpoint. The Call mediator will send the message using its |
|Define Inline||If this is selected, the endpoint to which the message should be sent can be included within the Call mediator configuration. Click Add to add the required endpoint. For more information on Adding an endpoint, see Adding an Endpoint.|
|Pick From Registry||If this is selected, the message can be sent to a pre-defined endpoint which is currently saved as a resource in the registry. Click either Configuration Registry or Governance Registry as relevant to select the required endpoint from the resource tree.|
If this is selected, the endpoint to which the message should be sent will be derived via an XPath expression. You are required to enter the relevant XPath expression in the text field that appears when this option is selected.
You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression.
|Blocking||If set to |
Example 1 - Service orchestration
In this example, the Call mediator invokes a backend service. An Enrich mediator stores the response received for that service invocation.
The Filter Mediator added after the Call mediator carries out a filter to determine whether the first call has been successful. If it is successful, second backend service is invoked. The payload of the request to the second backend is the response of the first service invocation.
After a successful second backend service invocation, response of the first service is retrieved by the Enrich mediator from the property where it was formerly stored. This response is sent to the client by the Respond mediator.
If it is not successful, a custom JSON error message is sent with HTTP 500. If the first call itself is not successful, the output is just sent back with the relevant error code.
Example 2 - Continuing mediation without waiting for responses
In this example, the message will be cloned by the Clone Mediator and sent via the Call mediator. The Drop mediator drops the response so that no further mediation is carried out for the cloned message. However, since the
continueParent attribute of the Clone mediator is set to
true, the original message is mediated in parallel. Therefore, the Log Mediator at the end of the configuration will log the
After call mediator log message without waiting for the Call mediator response.
Example 3 - Call mediator in blocking mode
In the following sample configuration, the Header Mediator is used to add the action, the PayloadFactory Mediator is used to store the the request message and the Call mediator is used to invoke a backend service.
You will see that the payload of the request and header action are sent to the backend. After successful backend service invocation, you will see that the response of the service is retrieved by the ESB and sent to the client as the response using the Respond Mediator.
Example 4 - Receiving response headers in blocking mode
If you want to receive the response message headers, when you use the Call mediator in blocking mode, add the
BLOCKING_SENDER_PRESERVE_REQ_HEADERS property within the proxy service, or in a sequence as shown in the sample proxy configuration below.
Set the value of the
BLOCKING_SENDER_PRESERVE_REQ_HEADERS property to
false, to receive the response message headers. If you set it to
true, you cannot get the response headers, but the request headers will be preserved.
For another example, see Sample 500: Call Mediator for Non-Blocking Service Invocation.