This documentation is for WSO2 ESB version 4.5.0. View documentation for the latest release.

Send Mediator

The Send Mediator is used to send messages out of Synapse to some endpoint. The Send Mediator also copies any message context properties from the current message context to the reply message received on the execution of the send operation, so that the response could be correlated back to the request. Messages may be correlated by WS-A MessageID, or even simple custom text labels.



There are two modes of operation in a Send Mediator:

1. Sending a message using message-level information.                                 
2. Sending a message to a predefined endpoint.

If we do not provide an endpoint, it will try to send the message using the wsa:to address of the message. Also, if we use a Send Mediator in the out path of the ESB without specifying an endpoint, it will send the message as a reply.

If we provide an endpoint, it will send the message according to the information in the endpoint.
The Send Mediator is the only way to send a message out from the ESB. If you want to forward the message to an endpoint or to send the reply back, this mediator must be used.

The Send Mediator copies any message context properties from the current message context to the reply message received on the execution of the send operation so that the response could be correlated back to the request. Messages may be correlated by WS-A Message-ID, or even simple custom text labels. 

Note

A send operation may be blocking or non-blocking depending on the actual transport implementation used. As the default NIO-based http/s implementation does not block on a send, care must be taken if the same message must be sent and then further processed (e.g. transformed). In such a scenario, it maybe first required to clone the message into two copies and then perform processing to avoid conflicts.


Syntax

<send/>

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

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

UI Configuration

You can select the endpoint to be one of the following value:

None Endpoint Type

None Endpoint Type option means that there will be no endpoint set to the Sent Mediator.

Anonymous Endpoint Type

Allows to choose and add an Endpoint Type from the list:

  • Address Endpoint - An endpoint defined by specifying the EPR (Endpoint Reference) and other attributes of the configuration. This option defines the direct URL of the service.
  • Default Endpoint - An endpoint defined for adding QoS and other configurations to the endpoint which is resolved from the To address of the message context. This option defines additional configuration for the default target.
  • WSDL Endpoint - An endpoint definition based on a specified WSDL document. The WSDL document can be specified either as a URL or as an inlined definition within the configuration. This option defines the WSDL, Service and Port.
  • Failover Group - A group of Failover Endpoints which send messages to the listed endpoints with the following fail-over behavior. At the beginning, the endpoint listed first is selected as primary and all other endpoints are treated as backups. Incoming messages are always sent only to the primary endpoint. If the primary endpoint fails, the next active endpoint is selected as primary and the failed endpoint is marked as inactive. It defines the endpoints that the service will try to connect to in case of a failure. This will take place in a round robin manner.
  • Load-balance Group - A group of Load-balanced Endpoints, which distributes the messages (load) arriving at it among application members by evaluating the load balancing policy and any other relevant parameters. This option defines groups of endpoints for replicated services.The incoming requests will be directed to these endpoints in a round robin manner. These endpoints automatically handle the fail-over cases as well.

Note

You can manage endpoints from the "Manage Endpoint" panel which can be accessed from the Manage-> Mediation-> Endpoints menu from the left hand side bar.

Pick From Registry

It is possible to pick a path either from Configuration Registry or Governance Registry.

See Namespace for more information about choosing a path from the registry.

XPath

Allows to choose XPath from the Namespaces or to add a new one.

Refer to Namespace for more information about choosing a XPath from the Namespaces.


Example

The Send Mediator used in in-path and out-path.

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <in>
        <send>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
        </send>
        <drop/>
    </in>
    <out>
        <send/>
    </out>
</definitions>

In this configuration, the first send is used inside the In Mediator. Both request and response will go through the main sequence. But only request messages will go through the child mediators of in. Only response messages will go through the Out mediator. So the request will be forwarded to the endpoint with the given address. The Response will go through the second send and this Send Mediator will send it back to the requester.