0

I am trying to implement cache in mule CE using MongoDB, found this-@PontusUllgren answer, so I ma trying on replacing EhCache with MongoDB. This is the bean:

    <spring:bean id="MyCache" class="test.someclass" init-method="initialize">
        <spring:property name="host" value="localhost"/>
        <spring:property name="port" value="27017"/>
        <spring:property name="database" value="test"/>
        <spring:property name="username" value="test"/>
        <spring:property name="writeConcern" value="DATABASE_DEFAULT"/>
        <spring:property name="entryTTL" value="600000" />
        <spring:property name="maxEntries" value="-1" />
        <spring:property name="expirationInterval" value="1000" />
    </spring:bean> 

and this is the <custom-interceptor/>:

    <custom-interceptor doc:name="PayloadCache"    class="test.someclass">  
      <spring:property name="cache" ref="MyCache"/>  
    </custom-interceptor> 

So my question is what should replace with the test.someclass java class?

EDIT:

I have added to my flow the mongodb connector configuration:

<mongo:config name="Mongo_DB" username="test" database="test" doc:name="Mongo DB"/>

than passed it to the custom-interceptor:

<custom-interceptor doc:name="PayloadCache"    class="test.someclass">  
      <spring:property name="cache" ref="Mongo_DB"/>  
</custom-interceptor>

but again, where will I get the someclass from?

Community
  • 1
  • 1
user2016
  • 153
  • 1
  • 5
  • 18

1 Answers1

0

The someclass should be a mongo connector class from mule, that xml configuration block should be replaced completely by a mongo configuration block with all the needed parameters as described in the docs here.

https://docs.mulesoft.com/mule-user-guide/v/3.7/mongodb-connector

Mauro Rocco
  • 4,980
  • 1
  • 26
  • 40
  • "The someclass should be a mongo connector class from mule", what are you referring to? where will I find that class? and how does it exactly fit the cache strategy? – user2016 Jan 19 '16 at 09:31
  • Your cache strategy needs to use a store, in your case you want to store in a mongo db. For doing that you need to initialize a mongo db connector bean that can be found in the module I linked you. Than you pass it to your interceptor as you show in the question and than you need to adapt the class that will actually store the payload to use mongodb connector methods. – Mauro Rocco Jan 19 '16 at 10:00
  • "than you need to adapt the class that will actually store the payload to use mongodb connector methods", Where will I adapt that class form? – user2016 Jan 19 '16 at 10:11
  • Well your SomeClass has to be written by you. You can use has template the one linked in your question called PayloadCache but in place of receiving an ecache object your are receiving a MongoCloudConnector object (https://github.com/houssoli/mule-mongo-connector/blob/master/src/main/java/org/mule/module/mongo/MongoCloudConnector.java). – Mauro Rocco Jan 19 '16 at 10:45
  • so that's my issue I am not sure how to convert the "PayloadCache" java class to use mongo object – user2016 Jan 19 '16 at 10:57
  • That's java development skills :-). If you know java it should come out easy. Sadly I don't have the time to code it for you. Hopefully someone else will. – Mauro Rocco Jan 19 '16 at 11:04