This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This section explains the best practices to be followed when creating mediation sequences in the following scenarios.

Last mediator in a sequence

The last mediator in a mediation sequence should be one of the following mediators depending on the scenario. Any mediator added after one of the following mediators will not be applied.

  • Drop mediator: when you want to stop the mediation flow at a particular point (e.g., when a filter condition is not met).
  • Loopback mediator: when you want the message to be moved from the In sequence to the Out sequence. Note that the Loopback mediator only prevents the subsequent mediators in the In sequence from being applied.
  • Respond mediator: when you want the message to be sent back to the client. 
  • Send Mediator: when you want the message to be sent to the specified endpoint. If a message should be further mediated after it is sent, you can use the Clone mediator to make two copies of the message and process them separately, thereby avoiding conflicts.

Defining the In and Out sequences

The In and Out sequences are separately defined for proxy services and REST APIs. Therefore, In and Out mediators should not be used in proxy service and REST API configurations. However, they should be used in the main sequence.

The correct usage of the Loopback mediator

Once a message has been passed from the In sequence (request path) to the Out sequence (response path), it cannot be moved to the Out sequence again via the Loopback mediator.

Sending a message back to the client

To send a message back to a client after it has passed through all the mediators in an In sequence, the Respond mediator can be added as the last mediator in the sequence.

Note that this cannot be carried out by adding a Send mediator without an endpoint as a child mediator of the Out mediator. In and Out mediators are used to define whether their child mediators are applicable to messages in the In or Out path when the Main sequence is called. They do not determine the direction in which the message is sent.

  • No labels