0

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

4

1 回答 1

0

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

流A

<?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>

流B

<?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 中的更新值。

我们可以将域中的对象存储配置为跨应用程序共享。请检查对象存储的域示例配置

于 2017-01-19T17:04:40.093 回答