[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>&lt;api \
xmlns=&quot;<a href="http://ws.apache.org/ns/synapse">http://ws.apache.org/ns/synapse</a>&quot; \
name=&quot;TestAPI&quot; context=&quot;/abc&quot;&gt;</div><div>     &lt;resource \
methods=&quot;GET&quot; uri-template=&quot;/instance/info/{id}&quot;&gt;</div><div>   \
&lt;inSequence&gt;</div><div>              &lt;log&gt;</div><div>                  \
&lt;property name=&quot;in&quot; value=&quot;===== IN =====&quot;/&gt;</div><div>     \
&lt;/log&gt;</div><div>              &lt;cache scope=&quot;per-host&quot;</div><div>  \
collector=&quot;false&quot;</div><div>                        \
hashGenerator=&quot;org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator&quot;</div><div> \
timeout=&quot;60&quot;&gt;</div><div>                  &lt;onCacheHit&gt;</div><div>  \
&lt;log&gt;</div><div>                           &lt;property \
name=&quot;cachehit&quot; value=&quot;Cache is hit&quot;/&gt;</div><div>              \
&lt;/log&gt;</div><div>                  &lt;/onCacheHit&gt;</div><div>               \
&lt;implementation type=&quot;memory&quot; maxSize=&quot;100&quot;/&gt;</div><div>    \
&lt;/cache&gt;</div><div>              &lt;send&gt;</div><div>                  \
&lt;endpoint&gt;</div><div>                       &lt;http uri-template=&quot;<a \
href="http://www.mocky.io/v2/5a158a1f2e00005f00eab752">http://www.mocky.io/v2/5a158a1f2e00005f00eab752</a>&quot;/&gt;</div><div> \
&lt;/endpoint&gt;</div><div>              &lt;/send&gt;</div><div>         \
&lt;/inSequence&gt;</div><div>         &lt;outSequence&gt;</div><div>              \
&lt;log&gt;</div><div>                  &lt;property name=&quot;out&quot; \
value=&quot;=== OUT ====&quot;/&gt;</div><div>              &lt;/log&gt;</div><div>   \
&lt;cache scope=&quot;per-host&quot; collector=&quot;true&quot;/&gt;</div><div>       \
&lt;send/&gt;</div><div>         &lt;/outSequence&gt;</div><div>     \
&lt;/resource&gt;</div><div>&lt;/api&gt;</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">&lt;<a href="mailto:dilusha@wso2.com" \
target="_blank">dilusha@wso2.com</a>&gt;</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">&lt;api xmlns=&quot;<a href="http://ws.apache.org/ns/synapse" \
target="_blank">http://ws.apache.org/<wbr>ns/synapse</a>&quot; \
name=&quot;Durdan&quot; context=&quot;/test&quot;&gt;</div><div \
style="font-size:15px">  &lt;resource methods=&quot;GET&quot; \
uri-template=&quot;/{+patientId}&quot;&gt;</div><div style="font-size:15px">         \
&lt;inSequence&gt;</div><div style="font-size:15px">              &lt;property \
name=&quot;SymboValue&quot; \
expression=&quot;get-property(&#39;uri.<wbr>var.patientId)&quot;/&gt;</div><div><span \
style="font-size:15px">              &lt;cache id=&quot;someCache&quot; \
scope=&quot;per-host&quot; collector=&quot;false&quot; \
hashGenerator=&quot;org.wso2.<wbr>carbon.mediator.cache.digest.<wbr>REQUESTHASHGenerator&quot; \
timeout=&quot;60&quot;&gt;</span></div><div><span style="font-size:15px">            \
&lt;implementation type=&quot;memory&quot; \
maxSize=&quot;10&quot;/&gt;</span></div><div><span style="font-size:15px">        \
&lt;/cache&gt;</span></div><div><span style="font-size:15px">                         \
&lt;log&gt;</span></div><div><span style="font-size:15px">                           \
&lt;property name=&quot;88888888888888&quot; value=&quot;out the \
sequence&quot;/&gt;</span></div><div><span style="font-size:15px">                    \
&lt;/log&gt;</span></div><div><span style="font-size:15px">                       \
&lt;payloadFactory media-type=&quot;xml&quot;&gt;</span></div><div><span \
style="font-size:15px">                           \
&lt;format&gt;</span></div><div><span style="font-size:15px">                         \
&lt;soapenv:Envelope xmlns:soapenv=&quot;<a \
href="http://schemas.xmlsoap.org/soap/envelope/" \
target="_blank">http://schemas.<wbr>xmlsoap.org/soap/envelope/</a>&quot;&gt;</span></div><div><span \
style="font-size:15px">                                    \
&lt;soapenv:Header&gt;</span></div><div><span style="font-size:15px">                 \
&lt;some&gt;12&lt;/some&gt;</span></div><div><span style="font-size:15px">            \
&lt;/soapenv:Header&gt;</span></div><div><span style="font-size:15px">                \
&lt;soapenv:Body&gt;</span></div><div><span style="font-size:15px">                   \
&lt;ser:readMediData xmlns:ser=&quot;<a href="http://service.sample.durdans.com" \
target="_blank">http://service.<wbr>sample.durdans.com</a>&quot;&gt;</span></div><div><span \
style="font-size:15px">                                             \
&lt;ser:patientId&gt;$1&lt;/ser:<wbr>patientId&gt;</span></div><div><span \
style="font-size:15px">                                         \
&lt;/ser:readMediData&gt;</span></div><div><span style="font-size:15px">              \
&lt;/soapenv:Body&gt;</span></div><div><span style="font-size:15px">                  \
&lt;/soapenv:Envelope&gt;</span></div><div><span style="font-size:15px">              \
&lt;/format&gt;</span></div><div><span style="font-size:15px">                        \
&lt;args&gt;</span></div><div><span style="font-size:15px">                           \
&lt;arg evaluator=&quot;xml&quot; \
expression=&quot;get-property(&#39;uri.<wbr>var.patientId&#39;)&quot;/&gt;</span></div><div><span \
style="font-size:15px">                           \
&lt;/args&gt;</span></div><div><span style="font-size:15px">                       \
&lt;/payloadFactory&gt;</span></div><div style="font-size:15px">              \
&lt;header name=&quot;Action&quot; \
value=&quot;urn:<wbr>readMediDataRecords&quot;/&gt;</div><div style="font-size:15px"> \
&lt;property name=&quot;SOAPAction&quot; value=&quot;urn:readMediData&quot; \
scope=&quot;transport&quot;/&gt;</div><div style="font-size:15px">              \
&lt;send&gt;</div><div style="font-size:15px">                  \
&lt;endpoint&gt;</div><div style="font-size:15px">                       &lt;address \
uri=&quot;Endpoint URL&quot; format=&quot;soap11&quot;/&gt;</div><div \
style="font-size:15px">                  &lt;/endpoint&gt;</div><div \
style="font-size:15px">              &lt;/send&gt;</div><div style="font-size:15px">  \
&lt;/inSequence&gt;</div><div style="font-size:15px">         \
&lt;outSequence&gt;</div><div><span style="font-size:15px">            &lt;cache \
id=&quot;someCache&quot; scope=&quot;per-host&quot; \
collector=&quot;true&quot;/&gt;</span><br></div><div style="font-size:15px">          \
&lt;send/&gt;</div><div style="font-size:15px">         \
&lt;/outSequence&gt;</div><div style="font-size:15px">     \
&lt;/resource&gt;</div><div style="font-size:15px">&lt;/api&gt;</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