简体   繁体   中英

Mule Cache - Cluster In Memory - deserialization issue

My Mule 3.9 application exposes a rest end point. Application is clustered and on-prem managed through Runtime Manager

Condition is: the end point which kicks off the batch process should be singleton meaning only 1 process should be running on the entire cluster. If a rest endpoint is invoked again, it should result into http status 409

For this use case, I have utilized Mule Caching - Clustered - In Memory version with below configuration

<ee:object-store-caching-strategy name="caching_strategy" doc:name="caching_strategy" keyGenerationExpression="some_key" synchronized="false" entryTTL="14400000" persistent="false" />

My flow looks like below -

<flow name="some-flow" doc:description="some-flow">
   <message-properties-transformer scope="invocation" doc:name="Intialize Message Properties" mimeType="application/java">
        <add-message-property key="messageId" value="#[message.rootId]"/>
   </message-properties-transformer>

<ee:cache doc:name="inititiation" cachingStrategy-ref="caching_strategy" >
    <logger message="process cache miss" level="INFO" doc:name="process cache miss"/>
    <set-payload doc:name="initialize cache map" value="#[{'id' : flowVars.messageId}]" />
</ee:cache>

<choice doc:name="Is process already running ?" >
    <when expression="#[payload.id == flowVars.messageId]">
        <logger message="New process started" level="INFO" />
    </when>
    <otherwise>
        <logger message="Process is already running" level="WARN" />
    </otherwise>
</choice>
</flow>

As you can see, I am putting java.util.HashMap with 1 key-value pair in cache and checking if it already exists or not

    <set-payload doc:name="initialize cache map" value="#[{'id' : flowVars.messageId}]" />

Actual functionality works great in the cluster and serves the purpose !

HOWEVER application logs are full of below **WARN** statements

org.mule.util.store.MonitoredObjectStoreWrapper - 
Running expirty on org.mule.util.store.ObjectStorePartition@4648ce75 threw java.lang.IllegalArgumentException: 
Cannot deserialize with a null classloader:
Cannot deserialize with a null classloader

I am not sure what is issue? The object which is in the cache is java.util.HashMap which is serializable and only key-value pair is of String.

I sense some class loader issue, but could not bring myself close to it.

Does anybody have any clue?

Thanks Vikas

Had my hands on the ground and managed to resolve the issue with below configuration -

<ee:object-store-caching-strategy name="caching_strategy" doc:name="caching_strategy" keyGenerationExpression="some_key" synchronized="false" >

    <!-- this is because my flow eturns different message than cache"
    <ee:serializable-event-copy-strategy/>

    <!-- manged store without persistance -->
    <managed-store storeName="MyTaskInMemoryStoreForClusteredCaching" 
               maxEntries="1" entryTTL="14400000" 
               expirationInterval="3660000" persistent="false"/>


</ee:object-store-caching-strategy>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM