我已经在wso2 esb中创建了一个应用程序接口来调用rest服务。我使用过缓存中介器,对于普通的GET方法来说,它工作得很好。
我想要的是,我已经使用了一个GET方法来获取员工的详细信息,我将传递带有url的employee_id。
对于给定的employee_id,此employee_id调用是第一次命中服务,然后对于同一API的下一次调用,它将从缓存本身获得响应,直至给定的超时时间段。如果我更改了employee_id,那么它应该命中服务,但它正在从缓存中获得响应。也适用于不同的employee_id。
我的API是,
<api xmlns="http://ws.apache.org/ns/synapse" name="cacheApi" context="/cacheApi">
<resource methods="GET" uri-template="/{id}/">
<inSequence>
<log/>
<cache id="" scope="per-host" collector="false" hashGenerator="org.wso2.carbon.mediator.cache.digest.DOMHASHGenerator" timeout="60">
<implementation type="memory" maxSize="10"/>
</cache>
<send>
<endpoint>
<http method="GET" uri-template="http://localhost:8080/rest-services/services/employee/{uri.var.id}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<cache scope="per-host" collector="true"/>
<send/>
</outSequence>
</resource>
</api>我的API调用将是as,
http://localhost:8280/cacheApi/1
http://localhost:8280/cacheApi/2
http://localhost:8280/cacheApi/3
....有人能帮我解决这个问题吗??
提前感谢
发布于 2016-03-12 08:36:28
您需要实现自己的散列生成器(实现org.wso2.carbon.mediator.cache.digest.DigestGenerator),因为org.wso2.carbon.mediator.cache.digest.DOMHASHGenerator散列仅基于请求/ msgContext.getEnvelope().getBody()的主体,不适用于您的msgContext.getEnvelope().getBody()。
发布于 2016-05-30 12:08:13
您可以尝试使用散列生成器的新实现,它也使用API URI来生成散列值。
为了应用这一点,请将散列生成器设置为org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator。
现在你的缓存中介器应该像这样,
<cache id="" scope="per-host" collector="false" hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator" timeout="60">
<implementation type="memory" maxSize="10"/>
</cache>(PS:我只对WSO2 ESB4.9.0发行版进行了测试。)
https://stackoverflow.com/questions/35150859
复制相似问题