Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Drop Mediator stops the processing of the current message and sends an HTTP 202 Accepted response to the client. 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.

...

Table of Contents
maxLevel3
minLevel3

...

styleborder:1
locationtop
typeflat
separatorpipe

...

Syntax

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

Code Block
XML
XML

<drop/>

UI Configuration

none.

Usage Scenario

Code Block
XML
XML

<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>

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

You can also use the drop mediator for messages that do not meet the filter criteria in case the client is waiting for a response to ensure the message was received by the ESB. For example:

Code Block
languagehtml/xml
<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>
...

In this scenario, if the message doesn't meet the filter condition, it is dropped, and the HTTP 202 Accepted response is sent to the client. If you did not include the drop mediator, the client would not receive any response.

Excerpt
hiddentrue

Description of the Drop Mediator in WSO2 ESB.