【问题标题】:how to cache response from endpoint in wso2 ESB如何在 wso2 ESB 中缓存来自端点的响应
【发布时间】:2015-11-21 04:32:24
【问题描述】:

我想在我的代理中缓存响应,当我再次点击我的代理时,它应该会为我获取缓存的数据。我曾尝试使用缓存调解器,但无法找到我的数据是否真的被缓存了。所以基本上我想要实现的是如果我在缓存中有数据,那么它不应该到达端点。它应该发送响应从缓存。期待您的回答。提前致谢

我的服务代码为:

public class GetMirrorValue {
    public String getValue(String data) throws Exception {
    System.out.println("Inside Service code");
        return data;
    }
}

我的顺序是:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="CheckCacheSeq">
   <cache scope="per-host" collector="false" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="20">
      <implementation type="memory" maxSize="100"/>
   </cache>
   <send>
      <endpoint key="DummyEP"/>
   </send>
</sequence>

我的输出顺序是:

<outSequence xmlns="http://ws.apache.org/ns/synapse">
   <cache scope="per-host" collector="true"/>
   <send/>
</outSequence>

但是每当我通过 try-it 工具连续访问我的代理服务时,我每次在我的服务器 System.out.println("Inside Service code");被打印?

【问题讨论】:

    标签: wso2 wso2esb


    【解决方案1】:

    您可以修改后端服务(代理服务调用的端点),以便在请求命中后在服务器日志中打印一些内容。第一个请求应该到达后端。然后在缓存期内,请求不会去后端服务。只有在缓存过期后才会转到后端服务。所以查看后端服务器日志上的打印,可以观察到缓存行为。

    http://docs.wso2.org/wiki/display/ESB460/Sample+420%3A+Simple+Cache+Implemented+on+ESB+for+the+Actual+Service

    【讨论】:

    • 我点击了链接。已经完成了完全相同的步骤,但我仍然得到上述问题中描述的结果
    • 在 CheckCacheSeq 中添加日志消息,以验证您的请求是否通过 CheckCacheSeq 序列路由(例如:在缓存中介之前和之后添加两条日志消息)。如果日志出现在碳日志中,请尝试增加缓存中介的超时值。
    【解决方案2】:

    您可以在 ESB 中启用有线日志以查看通过 ESB 的请求/响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多