【问题标题】:Mule 4 Cache Scope. How to stop mule cache for based on certain conditionsMule 4 缓存范围。如何根据某些条件停止骡子缓存
【发布时间】:2020-11-20 13:32:54
【问题描述】:

我想在我的 mule 应用程序中使用缓存。流程很简单,我是根据email查询数据库,我想只在返回一些行的情况下存储结果。我提到了这个问题Mule Cache Scope How to invalidate mule cache for no payload of DB output,但这个解决方案仅适用于mule 3,因为Mule 4 使用repeatable streams

我尝试实施以下解决方法:

  1. 将缓存作用域包装在 try 作用域内。
  2. 当我不想存储缓存时引发错误。
  3. 发生错误时继续错误仅针对该错误类型

它正确执行流程,不将结果存储在缓存中,也给出了成功的响应,但它抛出了一个错误(可能在一些异步进程中),我在我的日志中看到了这个

    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)

我也附上了我的流程的 sn-p。

【问题讨论】:

    标签: caching mule mulesoft mule-esb


    【解决方案1】:

    您可以使用Invalidate Key 操作将密钥添加到缓存后删除。

    它应该添加在缓存范围之后。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-28
      • 1970-01-01
      相关资源
      最近更新 更多