[英]Mule 4 Cache Scope. How to stop mule cache for based on certain conditions
我想在我的 mule 應用程序中使用緩存。 流程很簡單,我是根據email查詢數據庫,我只想在返回一些行時存儲結果。 我提到了這個問題Mule Cache Scope How to invalidate mule cache for no payload of DB output但這個解決方案只適用於 mule 3,因為 Mule 4 使用可重復的流。
我嘗試實施以下解決方法:
它正確執行流程,不將結果存儲在緩存中,也給出了成功的響應,但它拋出了一個錯誤(可能在某些異步進程中),我在我的日志中看到了這一點
ERROR 2020-11-20 17:54:36,923 [[MuleRuntime].uber.03: cachingStrategy_null @302bcf75] [processor: testFlow1/processors/1/processors/0/processors/1; event: 594def80-2b2b-11eb-a1d0-a0d37a4d6fab] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : The mapper returned a null value.
Element : testFlow1/processors/1/processors/0 @ test:test.xml:131 (Cache)
Element DSL : <ee:cache doc:name="Cache" doc:id="8c09cdc7-4fc9-4de1-a961-f74323f6ea7b" cachingStrategy-ref="Caching_Strategy">
<logger level="INFO" doc:name="Copy_of_Logger" doc:id="c539273d-7da2-4a20-bbdc-11f9fd4424cc" message="inside cache scope."></logger>
<ee:transform doc:name="Transform Message" doc:id="be16423b-c018-4949-b441-e81c6abc65ef">
<ee:message>
<ee:set-payload>%dw 2.0
output application/json
---
if(payload.store) {
id: payload.id,
time: now()
}
else {}</ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="cacheEntry">%dw 2.0
output application/java
...
Root Exception stack trace:
java.lang.NullPointerException: The mapper returned a null value.
at java.util.Objects.requireNonNull(Objects.java:228)
at reactor.core.* (4 elements filtered from stack; set debug level logging or '-Dmule.verbose.exceptions=true' for everything)(Unknown Source)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
我也附上了我的流程片段。
將密鑰添加到緩存后,您可以使用Invalidate Key操作將其刪除。
它應該添加在緩存范圍之后。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.