ObjectStore connector retrieve issue in mule

535 views Asked by At

I have one flow(A) with poll as source with transformation logic and storing result data in Mule Object Store Connector by overwriting latest value. Whenever I tried to retrieve(Using ObjectStore connector) the value in another flow(B). Note : Flow(B) is not called from flow A. I am able to get the value out of it for the first time. For the next time whenever It polls we should get the latest value and we are getting latest value in Flow A. whenever we are retrieving(Using ObjectStore connector) for latest value. It is giving last value only which stored the object store. Could you please provide the solution for this.

1

There are 1 answers

0
Jobin T On

Here's is my setup for Objectstore. We are using 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>

The table is updated using SQL independently. FlowA database polling gets the updated rows into the object store. And flowB correctly shows the updated values in objectstore.

We can configure the objectstore in domain to be shared across applications. Please check the Domain sample configuration for objectstore