[prev in list] [next in list] [prev in thread] [next in thread]
List: wsf-c-dev
Subject: Re: [Dev] How to configure the Cache mediator in ESB 5.0.0
From: Susankha Nirmala <susankha () wso2 ! com>
Date: 2017-11-29 9:57:48
Message-ID: CAKzOkCNX5X3nWFWzXh6EuF4_yCo8ksh-H6Kb+eQQwEt1LusBWQ () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Dilusha,
You can achieve your requirement with below sample API configuration.
<api xmlns="http://ws.apache.org/ns/synapse" name="TestAPI" context="/abc">
<resource methods="GET" uri-template="/instance/info/{id}">
<inSequence>
<log>
<property name="in" value="===== IN ====="/>
</log>
<cache scope="per-host"
collector="false"
hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator"
timeout="60">
<onCacheHit>
<log>
<property name="cachehit" value="Cache is hit"/>
</log>
</onCacheHit>
<implementation type="memory" maxSize="100"/>
</cache>
<send>
<endpoint>
<http uri-template="
http://www.mocky.io/v2/5a158a1f2e00005f00eab752"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log>
<property name="out" value="=== OUT ===="/>
</log>
<cache scope="per-host" collector="true"/>
<send/>
</outSequence>
</resource>
</api>
Thanks,
/Susankha.
On Wed, Nov 29, 2017 at 1:34 PM, Dilusha Alphonso <dilusha@wso2.com> wrote:
> Hi All,
>
> I have created an API in wso2 ESB 5.0.0 to call the SOAP back-end
> service. I have used cache mediator for a normal GET method. What I want
> is, I have used a GET Method to get some details, I passed the id with the
> URL.
>
> Requirement- When I call the service through API for a given id in the
> first time I need a proper response for particular id, then for next call
> for the same id it should get the response from the cache itself up-to-the
> given Timeout period. if I change the id then it should hit the service.
>
> I attached my configuration.
>
> <api xmlns="http://ws.apache.org/ns/synapse" name="Durdan"
> context="/test">
> <resource methods="GET" uri-template="/{+patientId}">
> <inSequence>
> <property name="SymboValue" expression="get-property('uri.
> var.patientId)"/>
> <cache id="someCache" scope="per-host" collector="false"
> hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator"
> timeout="60">
> <implementation type="memory" maxSize="10"/>
> </cache>
> <log>
> <property name="88888888888888" value="out the
> sequence"/>
> </log>
> <payloadFactory media-type="xml">
> <format>
> <soapenv:Envelope xmlns:soapenv="http://schemas.
> xmlsoap.org/soap/envelope/">
> <soapenv:Header>
> <some>12</some>
> </soapenv:Header>
> <soapenv:Body>
> <ser:readMediData xmlns:ser="http://service.
> sample.durdans.com">
> <ser:patientId>$1</ser:patientId>
> </ser:readMediData>
> </soapenv:Body>
> </soapenv:Envelope>
> </format>
> <args>
> <arg evaluator="xml" expression="get-property('uri.
> var.patientId')"/>
> </args>
> </payloadFactory>
> <header name="Action" value="urn:readMediDataRecords"/>
> <property name="SOAPAction" value="urn:readMediData"
> scope="transport"/>
> <send>
> <endpoint>
> <address uri="Endpoint URL" format="soap11"/>
> </endpoint>
> </send>
> </inSequence>
> <outSequence>
> <cache id="someCache" scope="per-host" collector="true"/>
> <send/>
> </outSequence>
> </resource>
> </api>
>
>
> Above configuration, I was able to get the response for proper id. but
> cache mediator is not working.
>
>
> Can anyone help me to solve this??
>
> Thanks in advance.
> --
>
>
> *Best Regards,Dilusha Alphonso*
>
> *Software Engineer - Support Team*
>
>
> *WSO2*
> *Mobile : *
>
> *+94766837098 <+94%2076%20683%207098>[image: http://wso2.com/signature]
> <http://wso2.com/signature>*
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
--
Susankha Nirmala
Senior Software Engineer
WSO2, Inc.: http://wso2.com
lean.enterprise.middleware
Mobile : +94 77 593 2146
blog : https://susankhanirmala.wordpress.com/
[Attachment #5 (text/html)]
<div dir="ltr"><div>Hi Dilusha,</div><div><br></div><div>You can achieve your \
requirement with below sample API configuration.</div><div><br></div><div><api \
xmlns="<a href="http://ws.apache.org/ns/synapse">http://ws.apache.org/ns/synapse</a>" \
name="TestAPI" context="/abc"></div><div> <resource \
methods="GET" uri-template="/instance/info/{id}"></div><div> \
<inSequence></div><div> <log></div><div> \
<property name="in" value="===== IN ====="/></div><div> \
</log></div><div> <cache scope="per-host"</div><div> \
collector="false"</div><div> \
hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator"</div><div> \
timeout="60"></div><div> <onCacheHit></div><div> \
<log></div><div> <property \
name="cachehit" value="Cache is hit"/></div><div> \
</log></div><div> </onCacheHit></div><div> \
<implementation type="memory" maxSize="100"/></div><div> \
</cache></div><div> <send></div><div> \
<endpoint></div><div> <http uri-template="<a \
href="http://www.mocky.io/v2/5a158a1f2e00005f00eab752">http://www.mocky.io/v2/5a158a1f2e00005f00eab752</a>"/></div><div> \
</endpoint></div><div> </send></div><div> \
</inSequence></div><div> <outSequence></div><div> \
<log></div><div> <property name="out" \
value="=== OUT ===="/></div><div> </log></div><div> \
<cache scope="per-host" collector="true"/></div><div> \
<send/></div><div> </outSequence></div><div> \
</resource></div><div></api></div><div><br></div><div>Thanks,</div><div>/Susankha.</div><div><br></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 29, 2017 at 1:34 PM, \
Dilusha Alphonso <span dir="ltr"><<a href="mailto:dilusha@wso2.com" \
target="_blank">dilusha@wso2.com</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div><font color="#242729" face="Arial, \
Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px">Hi \
All,</span></font></div><div><font color="#242729" face="Arial, Helvetica Neue, \
Helvetica, sans-serif"><span \
style="font-size:15px"><br></span></font></div><div><font color="#242729" \
face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px">I \
have created an API in wso2 ESB 5.0.0 to call the SOAP back-end service. I have \
used cache mediator for a normal GET method. What I want is, I have used a GET \
Method to get some details, I passed the id with the \
URL.</span><br></font></div><div><font color="#242729" face="Arial, Helvetica Neue, \
Helvetica, sans-serif"><span \
style="font-size:15px"><br></span></font></div><div><font color="#242729" \
face="Arial, Helvetica Neue, Helvetica, sans-serif"><span \
style="font-size:15px">Requirement- When I call the service through API for a given \
id in the first time I need a proper response for particular id, then for next call \
for the same id it should get the response from the cache itself up-to-the given \
Timeout period. if I change the id then it should hit the \
service.</span></font></div><div><font color="#242729" face="Arial, Helvetica Neue, \
Helvetica, sans-serif"><span \
style="font-size:15px"><br></span></font></div><div><font color="#242729" \
face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px">I \
attached my configuration.</span></font></div><div><font color="#242729" face="Arial, \
Helvetica Neue, Helvetica, sans-serif"><span \
style="font-size:15px"><br></span></font></div><div><font color="#242729" \
face="Arial, Helvetica Neue, Helvetica, sans-serif"><div \
style="font-size:15px"><api xmlns="<a href="http://ws.apache.org/ns/synapse" \
target="_blank">http://ws.apache.org/<wbr>ns/synapse</a>" \
name="Durdan" context="/test"></div><div \
style="font-size:15px"> <resource methods="GET" \
uri-template="/{+patientId}"></div><div style="font-size:15px"> \
<inSequence></div><div style="font-size:15px"> <property \
name="SymboValue" \
expression="get-property('uri.<wbr>var.patientId)"/></div><div><span \
style="font-size:15px"> <cache id="someCache" \
scope="per-host" collector="false" \
hashGenerator="org.wso2.<wbr>carbon.mediator.cache.digest.<wbr>REQUESTHASHGenerator" \
timeout="60"></span></div><div><span style="font-size:15px"> \
<implementation type="memory" \
maxSize="10"/></span></div><div><span style="font-size:15px"> \
</cache></span></div><div><span style="font-size:15px"> \
<log></span></div><div><span style="font-size:15px"> \
<property name="88888888888888" value="out the \
sequence"/></span></div><div><span style="font-size:15px"> \
</log></span></div><div><span style="font-size:15px"> \
<payloadFactory media-type="xml"></span></div><div><span \
style="font-size:15px"> \
<format></span></div><div><span style="font-size:15px"> \
<soapenv:Envelope xmlns:soapenv="<a \
href="http://schemas.xmlsoap.org/soap/envelope/" \
target="_blank">http://schemas.<wbr>xmlsoap.org/soap/envelope/</a>"></span></div><div><span \
style="font-size:15px"> \
<soapenv:Header></span></div><div><span style="font-size:15px"> \
<some>12</some></span></div><div><span style="font-size:15px"> \
</soapenv:Header></span></div><div><span style="font-size:15px"> \
<soapenv:Body></span></div><div><span style="font-size:15px"> \
<ser:readMediData xmlns:ser="<a href="http://service.sample.durdans.com" \
target="_blank">http://service.<wbr>sample.durdans.com</a>"></span></div><div><span \
style="font-size:15px"> \
<ser:patientId>$1</ser:<wbr>patientId></span></div><div><span \
style="font-size:15px"> \
</ser:readMediData></span></div><div><span style="font-size:15px"> \
</soapenv:Body></span></div><div><span style="font-size:15px"> \
</soapenv:Envelope></span></div><div><span style="font-size:15px"> \
</format></span></div><div><span style="font-size:15px"> \
<args></span></div><div><span style="font-size:15px"> \
<arg evaluator="xml" \
expression="get-property('uri.<wbr>var.patientId')"/></span></div><div><span \
style="font-size:15px"> \
</args></span></div><div><span style="font-size:15px"> \
</payloadFactory></span></div><div style="font-size:15px"> \
<header name="Action" \
value="urn:<wbr>readMediDataRecords"/></div><div style="font-size:15px"> \
<property name="SOAPAction" value="urn:readMediData" \
scope="transport"/></div><div style="font-size:15px"> \
<send></div><div style="font-size:15px"> \
<endpoint></div><div style="font-size:15px"> <address \
uri="Endpoint URL" format="soap11"/></div><div \
style="font-size:15px"> </endpoint></div><div \
style="font-size:15px"> </send></div><div style="font-size:15px"> \
</inSequence></div><div style="font-size:15px"> \
<outSequence></div><div><span style="font-size:15px"> <cache \
id="someCache" scope="per-host" \
collector="true"/></span><br></div><div style="font-size:15px"> \
<send/></div><div style="font-size:15px"> \
</outSequence></div><div style="font-size:15px"> \
</resource></div><div style="font-size:15px"></api></div><div \
style="font-size:15px"><br></div><div style="font-size:15px"><br></div><div \
style="font-size:15px">Above configuration, I was able to get the response for proper \
id. but cache mediator is not working.</div><div \
style="font-size:15px"><br></div><div style="font-size:15px"><br></div><div \
style="font-size:15px">Can anyone help me to solve this??<br></div><div \
style="font-size:15px"><br></div><div style="font-size:15px">Thanks in \
advance.</div><span class="HOEnZb"><font color="#888888"><div \
style="font-size:15px"><span \
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small">-- \
</span><br></div></font></span></font></div><span class="HOEnZb"><font \
color="#888888"><div class="m_6259089266914205720gmail_signature"><div \
dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div><div><div><font face="arial, helvetica, sans-serif"><b>Best \
Regards,<br>Dilusha Alphonso<br></b></font></div><font face="arial, helvetica, \
sans-serif"><b>Software Engineer - Support Team<br></b></font></div><font \
face="arial, helvetica, sans-serif"><b>WSO2<br><br></b></font></div><font \
face="arial, helvetica, sans-serif"><b>Mobile : </b></font><u><font face="arial, \
helvetica, sans-serif"><b><a href="tel:+94%2076%20683%207098" value="+94766837098" \
target="_blank">+94766837098</a></b></font><br><a href="http://wso2.com/signature" \
style="font-weight:bold" target="_blank"><img \
src="http://c.content.wso2.com/signatures/wso2-signature-general.png" \
alt="http://wso2.com/signature"></a><br></u></div></div></div></div></div></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
Dev mailing list<br>
<a href="mailto:Dev@wso2.org">Dev@wso2.org</a><br>
<a href="http://wso2.org/cgi-bin/mailman/listinfo/dev" rel="noreferrer" \
target="_blank">http://wso2.org/cgi-bin/<wbr>mailman/listinfo/dev</a><br> \
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div \
class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div \
dir="ltr"><span>Susankha</span> Nirmala<div>Senior Software \
Engineer<br></div><div><div style="color:rgb(136,136,136);font-family:arial"><span \
style="border-collapse:collapse;color:rgb(80,0,80)"><font face="arial, helvetica, \
sans-serif"><font color="#000000">WSO2, Inc</font>.: </font><font face="arial, \
helvetica, sans-serif"><font color="#000099"><a href="http://wso2.com/" \
style="color:rgb(92,69,32)" \
target="_blank">http://wso2.com</a></font></font></span></div><div \
style="color:rgb(136,136,136);font-family:arial"><span \
style="border-collapse:collapse;color:rgb(80,0,80)"><font face="arial, helvetica, \
sans-serif"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"><span>lean</sp \
an><span>.</span>enterprise<span>.</span>middleware</span></font></span></div></div><div \
style="color:rgb(136,136,136);font-family:arial"><span \
style="border-collapse:collapse;color:rgb(80,0,80)"><font face="arial, helvetica, \
sans-serif"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"><br></span></font></span></div><div \
style="color:rgb(136,136,136);font-family:arial"><span \
style="border-collapse:collapse;color:rgb(80,0,80)"><span \
style="color:rgb(34,34,34);font-family:arial,sans-serif">Mobile : +94 77 593 \
2146</span><font face="arial, helvetica, sans-serif"><span \
style="font-family:arial,sans-serif;color:rgb(0,0,0)"><br></span></font></span></div><div><span \
style="color:rgb(80,0,80);font-family:arial;border-collapse:collapse"><span \
style="color:rgb(34,34,34);font-family:arial,sans-serif">blog : </span></span><a \
href="https://susankhanirmala.wordpress.com/" \
target="_blank">https://susankhanirmala.wordpress.com/</a></div></div></div></div></div>
</div>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic