Hi Ruwan, I was able to use the cache mediator for above scenario by using a separate sequence for state 2 of the use case.
So If there is a cache hit, response will be taken from the memory and passed to the *reqCredit* Sequence. If there is no cache hit it will follow the same way and go it case *PERSON_INFO_REQUEST *and response will be put in to the cache memory. After that it will call the same sequence *reqCredit. * So it will work as Expected. I have attached the new Proxy configuration and Sequence configuration. Thank you, On Wed, Nov 18, 2015 at 11:01 PM, Ruwan Abeykoon <[email protected]> wrote: > Hi Devs, > I would like to know how we can cache the Response to first service only > when we adopt "Service Chaining Pattern" [1] > > For example, how I can cache the response (3) only and skip (2 and 3) for > subsequent requests until cache timeout occurs. [2] > > As far as I can understand, Cache mediator can not be used as > "collector=true" can be placed only at out-sequence. We need to put the > response collector on "in-sequence" > > [1] https://docs.wso2.com/display/ESB481/Service+Chaining+Example > [2] > https://docs.wso2.com/download/attachments/33136352/327.png?version=1&modificationDate=1391008346000&api=v2 > > -- > > *Ruwan Abeykoon* > *Architect,* > *WSO2, Inc. http://wso2.com <http://wso2.com/> * > *lean.enterprise.middleware.* > > email: [email protected] > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Viraj Senevirathne Software Engineer; WSO2, Inc. Mobile : +94 71 958 0269 Email : [email protected]
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="CreditProxy" transports="https http" startOnLoad="true" trace="disable"> <description/> <target> <inSequence> <log level="full"> <property name="sequence" value="inSequence - request for CreditProxy"/> </log> <property xmlns:sam="http://samples.esb.wso2.org" name="ORG_AMOUNT" expression="//sam:credit/sam:amount"/> <cache id="infoCache" scope="per-host" collector="false" hashGenerator="org.wso2.carbon.mediator.cache.digest.DOMHASHGenerator" timeout="60"> <onCacheHit sequence="reqCredit"/> <implementation type="memory" maxSize="1000"/> </cache> <property xmlns:sam="http://samples.esb.wso2.org" name="ORG_ID" expression="//sam:credit/sam:id"/> <enrich> <source type="inline" clone="true"> <sam:get xmlns:sam="http://samples.esb.wso2.org"> <sam:id>?</sam:id> </sam:get> </source> <target type="body"/> </enrich> <enrich> <source type="property" clone="true" property="ORG_ID"/> <target xmlns:sam="http://samples.esb.wso2.org" xpath="//sam:get/sam:id"/> </enrich> <log level="full"> <property name="sequence" value="inSequence - request for PersonInfoService"/> </log> <property name="STATE" value="PERSON_INFO_REQUEST"/> <send> <endpoint key="PersonInfoEpr"/> </send> </inSequence> <outSequence> <switch source="get-property('STATE')"> <case regex="PERSON_INFO_REQUEST"> <cache id="infoCache" scope="per-host" collector="true"/> <sequence key="reqCredit"/> </case> <case regex="CREDIT_REQUEST"> <log level="full"> <property name="sequence" value="outSequence - STATE 02 - response from CreditService"/> </log> <send/> </case> </switch> </outSequence> </target> <publishWSDL uri="file:resources/CreditProxy.wsdl"/> </proxy>
<?xml version="1.0" encoding="UTF-8"?> <sequence xmlns="http://ws.apache.org/ns/synapse" name="reqCredit" trace="disable"> <log level="full"> <property name="sequence" value="outSequence - STATE 01 - response from PersonInfoService"/> </log> <xslt key="xslt"> <property xmlns:ns3="http://org.apache.synapse/xsd" name="amount" expression="get-property('ORG_AMOUNT')"/> </xslt> <log level="full"> <property name="sequence" value="outSequence - STATE 01 - request for CreditService"/> </log> <property name="STATE" value="CREDIT_REQUEST"/> <send> <endpoint key="CreditEpr"/> </send> </sequence>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
