ObjectStore连接器检索mule中的问题

时间:2017-01-05 07:14:43

标签: mule mule-studio mule-component mule-el mule-cluster

我有一个带有轮询的流程(A)作为具有转换逻辑的源,并通过覆盖最新值将结果数据存储在Mule对象存储连接器中。每当我尝试检索(使用ObjectStore连接器)另一个流(B)中的值。 注意:不从流程A调用流程(B)。 我第一次能够从中获得价值。下次每当它轮询我们应该得到最新的值,并且我们在流程A中获得最新值。每当我们检索(使用ObjectStore连接器)获取最新值时。它仅提供存储对象存储的最后一个值。 能否为您提供解决方案。

1 个答案:

答案 0 :(得分:0)

这是我对Objectstore的设置。我们正在使用Mule 3.8.2。

<强> FlowA

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore"
xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
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/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd">
<db:oracle-config name="Oracle_Configuration" host="${db.host}"
        port="${db.port}" instance="${db.instance}" user="${db.user}"
        password="${db.password}" doc:name="Oracle Configuration" />
<objectstore:config name="ObjectStore__Connector"
        doc:name="ObjectStore: Connector" />
<flow name="flowA">
    <poll doc:name="Poll">
        <fixed-frequency-scheduler frequency="20000"
                startDelay="20000" />
        <db:select config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select oprt_id from 
    table where column = 'Y']]></db:parameterized-query>
        </db:select>
    </poll>
    <choice doc:name="Choice">
        <when expression="#[payload.size() &gt; 0]">
            <objectstore:store config-ref="ObjectStore__Connector"
                    key="keyName" value-ref="#[payload.toString()]" doc:name="ObjectStore"
                    overwrite="true" />
            <logger message="after storing    #[payload]" level="INFO"
                    doc:name="Logger" />
        </when>
        <otherwise>
            <logger message="No data in table" level="INFO" doc:name="Logger" />
        </otherwise>
    </choice>
</flow>
</mule>

<强> FlowB

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd 
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:listener-config name="HTTP_Listener_Configuration"
    host="0.0.0.0" port="40955" doc:name="HTTP Listener Configuration" />
<flow name="flowB">
    <http:listener config-ref="HTTP_Listener_Configuration"
        path="/retrieve" allowedMethods="GET" doc:name="HTTP" />
    <logger message="#['Inside Flow A '+message]" level="INFO"
        doc:name="Logger" />
    <objectstore:retrieve config-ref="ObjectStore__Connector"
        doc:name="ObjectStore" key="keyName" />
    <logger message="#['ObjectStore Value='+payload]" level="INFO"
        doc:name="Logger" />
</flow>
</mule>

该表使用SQL独立更新。 FlowA数据库轮询将更新的行放入对象库中。 并且flowB正确显示了对象库中的更新值。

我们可以将域中的objectstore配置为跨应用程序共享。请查看Domain sample configuration for objectstore