Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:
repository/samples/directory that includes all Integration profile samples is changed to
repository/samples/resources/directory that includes all artifacts related to the Integration profile samples is changed to
Objective: Demonstrate the use of Cache mediator in order to cache the response and use that cached response as the response for an identical xml request.
- Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.
- Start ESB with the sample configuration 420 (i.e. wso2ei-samples -sn 420).
In this sample, the message sent to ESB is checked for an existing cached response by calculating the hash value of the request. If there is a cache hit in ESB then this request will not be forwarded to the actual service, rather ESB respond to the client with the cached response. In case of a cache miss that particular message will be forwarded to the actual service and cached that response in the out path for the use of consecutive requests of the same type.
To observe this behavior, invoke the client as follows.
You could notice that if you send more than one requests within 20 seconds only the first request is forwarded to the actual service, and the rest of the requests will be served by the cache inside ESB. You could observe this by looking at the printed line of the axis2 server, as well as by observing a constant rate as the response to the client instead of the random rate, which changes by each and every 20 seconds.
The Callout mediator calls the given service URL with the request message which is given by the source attribute, waits for the response and attaches the received response to the destination which is given by the target attribute. Both the source and the target can be a key or an XPath. In the case of the source, this key refers to either a message context property or to a local entry. For the target, this key refers to a message context property only.