How to use Object Store
03-04-2017
Abstract
• The Object Store Connector lets you connect
to the object storage facility in Mule and
exposes convenient methods for exploiting
the capabilities of Mule Object Stores.
Internally, Mule uses object stores in various
filters, routers, and other message processors
that need to store state between messages.
Example
• .mflow
• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
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.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
• http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd
• http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd">
• <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8089" doc:name="HTTP Listener Configuration"/>
• <objectstore:config name="ObjectStore__Connector" doc:name="ObjectStore: Connector" partition="abc"/>
• <flow name="ObjectStoreFlow">
• <quartz:inbound-endpoint jobName="myjob" repeatInterval="10000" responseTimeout="10000" doc:name="Quartz">
• <quartz:event-generator-job/>
• </quartz:inbound-endpoint>
• <logger message="---Store flow--------" level="INFO" doc:name="Logger"/>
• <expression-component doc:name="Expression"><![CDATA[import java.util.*;
• Map m1 = new HashMap();
• m1.put("Database","Connector");
• m1.put("Cache","Scope");
• m1.put("Object to String","Transformer");
• m1.put("And","Filter");
• m1.put("Choice","Flow Control");
• payload = m1;
• ]]></expression-component>
• <objectstore:store config-ref="ObjectStore__Connector" key="mule" value-ref="#[payload]" doc:name="ObjectStore" overwrite="true"/>
• </flow>
• <flow name="ObjectStoreFlow1">
• <http:listener config-ref="HTTP_Listener_Configuration" path="/objectstore" doc:name="HTTP"/>
• <logger message="---Retrive flow-------" level="INFO" doc:name="Logger"/>
• <set-variable variableName="myvariable" value="0" doc:name="Variable"/>
• <objectstore:retrieve config-ref="ObjectStore__Connector" key="mule" defaultValue-ref="#[flowVars.myvariable]" targetProperty="muleflow" targetScope="SESSION"
doc:name="ObjectStore"/>
• <logger message="----#[sessionVars.muleflow.get(message.inboundProperties.'http.query.params'.key)]---" level="INFO" doc:name="Logger"/>
• <set-payload value="#[sessionVars.muleflow.get(message.inboundProperties.'http.query.params'.key)]" doc:name="Set Payload"/>
• </flow>
• </mule>
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.8/object-store-connector

Object store

  • 1.
    How to useObject Store 03-04-2017
  • 2.
    Abstract • The ObjectStore Connector lets you connect to the object storage facility in Mule and exposes convenient methods for exploiting the capabilities of Mule Object Stores. Internally, Mule uses object stores in various filters, routers, and other message processors that need to store state between messages.
  • 3.
  • 4.
    • .mflow • <?xmlversion="1.0" encoding="UTF-8"?> • <mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 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.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd • http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd • http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd"> • <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8089" doc:name="HTTP Listener Configuration"/> • <objectstore:config name="ObjectStore__Connector" doc:name="ObjectStore: Connector" partition="abc"/> • <flow name="ObjectStoreFlow"> • <quartz:inbound-endpoint jobName="myjob" repeatInterval="10000" responseTimeout="10000" doc:name="Quartz"> • <quartz:event-generator-job/> • </quartz:inbound-endpoint> • <logger message="---Store flow--------" level="INFO" doc:name="Logger"/> • <expression-component doc:name="Expression"><![CDATA[import java.util.*; • Map m1 = new HashMap(); • m1.put("Database","Connector"); • m1.put("Cache","Scope"); • m1.put("Object to String","Transformer"); • m1.put("And","Filter"); • m1.put("Choice","Flow Control"); • payload = m1; • ]]></expression-component> • <objectstore:store config-ref="ObjectStore__Connector" key="mule" value-ref="#[payload]" doc:name="ObjectStore" overwrite="true"/> • </flow> • <flow name="ObjectStoreFlow1"> • <http:listener config-ref="HTTP_Listener_Configuration" path="/objectstore" doc:name="HTTP"/> • <logger message="---Retrive flow-------" level="INFO" doc:name="Logger"/> • <set-variable variableName="myvariable" value="0" doc:name="Variable"/> • <objectstore:retrieve config-ref="ObjectStore__Connector" key="mule" defaultValue-ref="#[flowVars.myvariable]" targetProperty="muleflow" targetScope="SESSION" doc:name="ObjectStore"/> • <logger message="----#[sessionVars.muleflow.get(message.inboundProperties.'http.query.params'.key)]---" level="INFO" doc:name="Logger"/> • <set-payload value="#[sessionVars.muleflow.get(message.inboundProperties.'http.query.params'.key)]" doc:name="Set Payload"/> • </flow> • </mule>
  • 7.