我试图在mule中为特定请求实现缓存策略,与MongoDB一起使用。
名称空间 - xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
schemalocation - http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd
尝试两种方式:
1)我配置了MongoDB连接器。
连接器 - <mongo:config name="Mongo_DB" doc:name="Mongo DB" database="test" username="test"/>
缓存的对象库 -
<ee:object-store-caching-strategy name="Mongo_DB_Caching_Strategy" doc:name="Caching Strategy">
<spring-object-store ref="Mongo_DB" />
</ee:object-store-caching-strategy>
但我收到了错误:
2)缓存的对象存储 - (其他方式):
像这样 - Mule Caching Strategy using Mongo DB <ee:object-store-caching-strategy name="Mongo_DB_Caching_Strategy" doc:name="Caching Strategy">
<custom-object-store class="org.mule.module.mongo.MongoObjectStore">
<spring:property name="database" value="test"/>
<spring:property name="host" value="localhost"/>
<spring:property name="port" value="27017"/>
<spring:property name="username" value="test"/>
</custom-object-store>
</ee:object-store-caching-strategy>
但是我得到同样的错误。
答案 0 :(得分:1)
此配置对我有用,并使用Spring实例化操作系统。
<spring:beans>
<spring:bean id="mongoObjectStore" class="org.mule.module.mongo.MongoObjectStore"
init-method="initialize" scope="singleton">
<spring:property name="host" value="localhost"/>
<spring:property name="port" value="27017"/>
<spring:property name="database" value="test"/>
<spring:property name="username" value=""/>
<spring:property name="password" value=""/>
<spring:property name="writeConcern" value="DATABASE_DEFAULT"/>
</spring:bean>
</spring:beans>
<ee:object-store-caching-strategy
name="mongoCachingStrategy">
<spring-object-store ref="mongoObjectStore" />
</ee:object-store-caching-strategy>