Created
October 22, 2016 19:35
-
-
Save fganora/d6df61ebb0fb490b8822ba86d7fe1d54 to your computer and use it in GitHub Desktop.
Mule: example register object into Mule registry and access it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd"> | |
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> | |
<global-property name="registryKey" value="myValuableString" doc:name="Global Property"/> | |
<flow name="registerObjectFlow"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/registerobject" allowedMethods="GET" doc:name="HTTP"/> | |
<set-variable variableName="value" value="#[message.inboundProperties.'http.query.params'.value]" doc:name="Set myString value"/> | |
<scripting:component doc:name="Register object"> | |
<scripting:script engine="Groovy"> | |
<![CDATA[muleContext.getRegistry().registerObject("${registryKey}", new String(flowVars.value))]]> | |
</scripting:script> | |
</scripting:component> | |
<set-payload value="#['Registered ${registryKey} = ' + flowVars.value]" doc:name="Set Payload"/> | |
</flow> | |
<flow name="lookupObjectFlow"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/lookupobject" allowedMethods="GET" doc:name="HTTP"/> | |
<scripting:component doc:name="Lookup object"> | |
<scripting:script engine="Groovy"><![CDATA[payload = muleContext.getRegistry().get("${registryKey}")]]></scripting:script> | |
</scripting:component> | |
<logger message="Value of ${registryKey} = #[payload]" level="INFO" doc:name="Logger"/> | |
</flow> | |
</mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment