使用Mongo DB的Mule缓存策略 [英] Mule Caching Strategy using Mongo DB

查看:135
本文介绍了使用Mongo DB的Mule缓存策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将org.mule.module.mongo.MongoObjectStore用作流中的缓存策略?

Is it possible to use the org.mule.module.mongo.MongoObjectStore as a cache strategy within a flow?

我尝试了以下操作,但出现错误

I have attempted with the following but I get the error

null(java.lang.NullPointerException)
org.mule.module.mongo.MongoObjectStore:382(空).

null (java.lang.NullPointerException)
org.mule.module.mongo.MongoObjectStore:382 (null).

<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/2.0/mule-mongo.xsd">

    <ee:object-store-caching-strategy name="Mongo_Caching_Strategy" doc:name="Caching Strategy">
        <custom-object-store class="org.mule.module.mongo.MongoObjectStore">
            <spring:property name="host" value="localhost"/>
            <spring:property name="port" value="27017"/>
            <spring:property name="database" value="test"/>
        </custom-object-store>
    </ee:object-store-caching-strategy>

    <flow name="htmlCacheFlow" doc:name="htmlCacheFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" path="cache" doc:name="HTTP"/>
        <expression-transformer expression="#[payload.substring(payload.lastIndexOf('/') + 1)]" doc:name="Expression"/>
        <ee:cache doc:name="Cache" cachingStrategy-ref="Mongo_Caching_Strategy" >
            <logger message="getting item from db for key #[payload]" level="INFO" doc:name="Logger"/>
            <expression-transformer expression="#[payload + 'asd']" doc:name="Expression"/>
        </ee:cache>
</flow>
</mule>

任何人都可以提供有关如何配置它的示例吗?

Could anyone provide an example on how to configure it?

推荐答案

尝试一下:

    <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:mos="http://www.mulesoft.org/schema/mule/mongo-object-store"
        xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
        xmlns:test="http://www.mulesoft.org/schema/mule/test" xmlns:spring="http://www.springframework.org/schema/beans"
        xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
        xsi:schemaLocation="
              http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
              http://www.mulesoft.org/schema/mule/mongo-object-store http://www.mulesoft.org/schema/mule/mongo-object-store/current/mule-mongo-object-store.xsd
              http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
              http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
              http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">

      <mos:config name="mos" database="test" />

      <ee:object-store-caching-strategy name="Mongo_Caching_Strategy">
           <spring-object-store ref="mos" />
        </ee:object-store-caching-strategy> 
    </mule>

请注意mos的特定名称空间.

Notice the specific namespaces for mos.

这篇关于使用Mongo DB的Mule缓存策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆