com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Call Mediator

The Call mediator is used to send messages out of the ESB profile 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 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 <EI_HOME>/conf/axis2/axis2_blocking_client.xml file as the Axis2 configuration.

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.



Set up

Enabling mutual SSL in the non-blocking mode

This is used for configuring non-blocking transport. When calling backends, if you use passthru transport for HTTPS calls (this is what you use by default when using send, call mediators) you need to configure axis2.xml's PassThroughHttpSSLSender.


 <transportSender name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLSender">
        <parameter name="non-blocking" locked="false">true</parameter>
        <parameter name="keystore" locked="false">
            <KeyStore>
                <Location>repository/resources/security/wso2carbon.jks</Location>
                <Type>JKS</Type>
                <Password>wso2carbon</Password>
                <KeyPassword>wso2carbon</KeyPassword>
            </KeyStore>
        </parameter>
        <parameter name="truststore" locked="false">
            <TrustStore>
                <Location>repository/resources/security/client-truststore.jks</Location>
                <Type>JKS</Type>
                <Password>wso2carbon</Password>
            </TrustStore>
        </parameter>
        <!--<parameter name="HostnameVerifier">DefaultAndLocalhost</parameter>-->
            <!--supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified -->
    </transportSender>


Enabling mutual SSL in the blocking mode

This is used, when you call backends in a blocking manner. Same thread will wait for response from backend to come.You can use call mediator in blocking way, but we need this for special cases only. HTTPS calls also possible with it. Keystore and trust-store configs are like below (you do not need to modify axis2_blocking_client.xml)

When using the Call mediator in the blocking mode  (blocking=true), enable the mediator to handle mutual SSL by adding the following JVM settings to the  <EI_HOME>/bin/integrator.sh  file.

Key-store - define as a system parameter in start up script (i.e <EI_HOME>/bin/integrator.sh):

-Djavax.net.ssl.keyStore="$CARBON_HOME/repository/resources/security/wso2carbon.jks" \
-Djavax.net.ssl.keyStorePassword="wso2carbon" \
-Djavax.net.ssl.keyPassword="wso2carbon" \
-Drampart.axiom.parser.pool=false \

Trust-store - defined at carbon.xml file:

 <!--System wide trust-store which is used to maintain the certificates of all the trusted parties.-->
        <TrustStore>
            <!-- trust-store file location -->
            <Location>${carbon.home}/repository/resources/security/client-truststore.jks</Location>
            <!-- trust-store type (JKS/PKCS12 etc.) -->
            <Type>JKS</Type>
            <!-- trust-store password -->
            <Password>wso2carbon</Password>
        </TrustStore>

When using the Call mediator in the blocking mode <transportSender> elements need to enable transport senders in the axis2.xml file.


If you define trust-store as a system parameter, it will be get overriden by what is defined at carbon.xml. This cannot be avoided. Thus you need to define trust-store in above manner.

Syntax

<call [blocking="true"] />

If the message is to be sent to one or more endpoints, use the following syntax:

 
<call [blocking="true"]>
   (endpointref | endpoint)+
</call>
  • The endpointref token refers to the following:
<endpoint key="name"/>
  • The endpoint token refers to an anonymous endpoint definition.

Configuration

Select one of the following options to define the endpoint to which, the message should be delivered.

Parameter NameDescription
NoneSelect this option if you do not want to provide an endpoint. The Call mediator will send the message using its wsa:to address.
Define InlineIf 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 RegistryIf 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.
XPath

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 true, you can use the call mediator in blocking mode.

  • Axis2 Repository - The path to Axis2 client repository where the services and modules are located. The purpose of this parameter is to make the Call mediator initialize with the required client repository.
  • Axis2 XML - The path to the location of the Axis2.xml configuration file. The purpose of this parameter is to make the Call mediator initialize with the relevant Axis2 configurations.
  • initAxis2ClientOptions - If this parameter is set to false, the existing Axis2 client options available in the Synapse message context will be reused when the Call mediator is invoked. This is useful when you want to use NLTM authentication. The default value for this parameter is true.



Example

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.

<target>
      <inSequence>
         <log/>
         <call>
            <endpoint>
               <http method="get" uri-template="http://192.168.1.10:8088/mockaxis2service"/>
            </endpoint>
         </call>
         <enrich>
            <source type="body" clone="true"/>
            <target type="property" action="child" property="body_of_first_call"/>
         </enrich>
         <filter source="get-property('axis2', 'HTTP_SC')" regex="200">
            <then>
               <log level="custom">
                  <property name="switchlog" value="Case: first call successful"/>
               </log>
               <call>
                  <endpoint>
                     <http method="get" uri-template="http://localhost:8080/MockService1"/>
                  </endpoint>
               </call>
               <filter source="get-property('axis2', 'HTTP_SC')" regex="200">
                  <then>
                     <log level="custom">
                        <property name="switchlog" value="Case: second call successful"/>
                     </log>
                     <enrich>
                        <source type="property" clone="true" property="body_of_first_call"/>
                        <target type="body"/>
                     </enrich>
                     <respond/>
                  </then>
                  <else>
                     <log level="custom">
                        <property name="switchlog" value="Case: second call unsuccessful"/>
                     </log>
                     <property name="HTTP_SC" value="500" scope="axis2"/>
                     <payloadFactory media-type="json">
                        <format>{ "status": "ERROR!"}</format>
                        <args/>
                     </payloadFactory>
                     <respond/>
                  </else>
               </filter>
            </then>
            <else>
               <log level="custom">
                  <property name="switchlog" value="Case: first call unsuccessful"/>
               </log>
               <respond/>
            </else>
         </filter>
      </inSequence>
   </target>


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.

...
<log level="full"/>
<clone continueParent="true">
<target>
<sequence>
<call>
<endpoint>
<address uri="http://localhost:8080/echoString"/>
</endpoint>
</call>
<drop/>
</sequence>
</target>
</clone>
<log level="custom">
<property name="MESSAGE" value="After call mediator"/>
</log>
...
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 EI and sent to the client as the response using the Respond Mediator .

<target>
   <inSequence>
      <header name="Action" value="urn:getQuote" />
      <payloadFactory media-type="xml">
         <format>
            <m0:getQuote xmlns:m0="http://services.samples">
               <m0:request>
                  <m0:symbol>WSO2</m0:symbol>
               </m0:request>
            </m0:getQuote>
         </format>
         <args />
      </payloadFactory>
      <call blocking="true">
         <endpoint>
            <address uri="http://localhost:9000/services/SimpleStockQuoteService" />
         </endpoint>
      </call>
      <respond />
   </inSequence>
</target>
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.

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="sample"
       transports="https"
       statistics="enable"
       trace="enable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="FORCE_ERROR_ON_SOAP_FAULT"
                   value="true"
                   scope="default"
                   type="STRING"/>
         <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
         <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
         <property name="BLOCKING_SENDER_PRESERVE_REQ_HEADERS" value="false"/>
         <call blocking="true">
            <endpoint>
               <address uri="https://localhost:8243/services/sampleBE"
                        trace="enable"
                        statistics="enable"/>
            </endpoint>
         </call>
         
      </inSequence>
      <outSequence/>
   </target>
   <description/>
</proxy>

Samples

For another example, see /wiki/spaces/EI6xx/pages/49611349.

If you define trust-store as a system parameter, it will be get overriden by what is defined at carbon.xml. This cannot be avoided. Thus you need to define trust-store in above manner.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.