This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Drop Mediator

The Drop Mediator stops the processing of the current message. This mediator is useful for ensuring that the message is sent only once and then dropped by the ESB. If you have any mediators defined after the <drop/> element, they will not be executed, because <drop/> is considered to be the end of the message flow.

When the Drop mediator is included in the in sequence, it sends an HTTP 202 Accepted response to the client when it stops the message flow. When the Drop mediator is included in the out sequence before the Send mediator, no response is sent to the client.



Syntax

The drop token refers to a <drop> element, which is used to stop further processing of a message:

<drop/>

UI Configuration

As with other mediators, after adding the drop mediator to a sequence, you can change its position in the sequence by moving it up or down using the arrows.

Examples

Example 1: Dropping a message after it is sent to an endpoint

In this example, the message is dropped after it is sent to the endpoint. This will prevent the message from being sent twice from the in-path.

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <filter source="get-property('To')" regex=".*/StockQuote.*">
        <send>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
        </send>
        <drop/>
    </filter>
    <send/>
</definitions>

Example 2: Dropping messages that do not meet the filter criteria

You can also use the drop mediator for messages that do not meet the filter criteria if the client is waiting for a response to ensure the message was received by the ESB. When the Drop mediator is included in a proxy configuration as shown below, the message is dropped and the HTTP 202 Accepted response is sent to the client in a situation where the message does not meet the filter criteria. If the Drop mediator is not included in the configuration, no response is sent to the client.

<definitions xmlns="http://ws.apache.org/ns/synapse">
  <sequence name="main">
     <in>
     <!-- filtering of messages with XPath and regex matches -->
       <filter source="get-property('To')" regex=".*/StockQuote.*">
          <then>
             <send>
                <endpoint>
                   <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
               </endpoint>
             </send>
          </then>
		  <else>
             <drop/>
		  </else>
     </filter>
...