[英]How to get the Cache Event Key from Mule
我正在使用Anypoint Studio 6.1和Mule 3.8.1,并且具有使用默认事件密钥生成的Mule托管存储缓存策略。
如何在流程中获取此键的值? 它存储在哪里?
谢谢
默认情况下,如果您在缓存中未提供密钥生成器表达式,则生成器将SHA 256 hash
作为密钥提供。
参考:-https: //github.com/mulesoft/mule/blob/mule-3.x/core/src/main/java/org/mule/keygenerator/SHA256MuleEventKeyGenerator.java
该生成器计算当前消息字节有效负载的SHA 256 hash
。
您可以使用以下示例获取流的缓存键列表:-
<ee:object-store-caching-strategy name="cachingStrategy" doc:name="cachingStrategy">
<managed-store storeName="myNonPersistentManagedObjectStore" maxEntries="-1" entryTTL="20000" expirationInterval="5000"/>
</ee:object-store-caching-strategy>
<flow name="keylist" doc:name="keylist">
<http:listener config-ref="HTTP_Listener_Configuration" path="/getkeyvalue" doc:name="HTTP"/>
<scripting:component doc:name="Initialise Database">
<scripting:script engine="Groovy">
<scripting:text><![CDATA[
def keyValues = [];
for(a=0;a<muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().size();a++)
{
keyValues = muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().get(a);
}
if(keyValues.isEmpty())
{
return "Key is either null or expired !!!";
}
else
{
return "KeysList " + muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().toString();
}
]]></scripting:text>
</scripting:script>
</scripting:component>
</flow>
每当您在缓存中添加一些消息时,使用上述流程,您都可以获得默认缓存键值的所有列表,这些默认缓存键值由缓存范围默认提供为SHA 256 hash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.