【问题标题】:ObjectStore connector retrieve issue in muleObjectStore 连接器在 mule 中检索问题
【发布时间】:2017-05-19 15:39:34
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    这是我对 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 中的更新值。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      相关资源
      最近更新 更多