Reputation: 4654
<sub-flow name="SendToEMC">
<until-successful objectStore-ref="objectStore" maxRetries="${MaximumRetry}" secondsBetweenRetries="${RetryInterval}">
<http:outbound-endpoint address="${EMCURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
</until-successful>
</sub-flow>
<expression-component>app.registry.messageBean.messageProcessedSuccessfully(flowVars.id)</expression-component>
I need to execute the expression-component after until-successful tag, only if it actually successes! but when i try to use Synchronous = true with until-successful i got this error :
Until successful cannot be configured to be synchronous and use an object store.
I tried to use below work around but it seems not to work :
<sub-flow name="SendToEMC">
<until-successful objectStore-ref="objectStore" maxRetries="${MaximumRetry}" secondsBetweenRetries="${RetryInterval}">
<processor-chain>
<http:outbound-endpoint address="${EMCURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
<expression-component>app.registry.messageBean.messageProcessedSuccessfully(flowVars.id)</expression-component>
</processor-chain>
</until-successful>
</sub-flow>
What am i doing wrong? and how can i achieve this?
thank you
Upvotes: 0
Views: 3143
Reputation: 1
If you aren't using OBJECT STORE REF use threading as - SYNCHRONOUS.
If you are using listable object store ref inside Until Successful use Async.
Upvotes: 0
Reputation: 131
Good scenario for the ObjectStore connector! First some observations of your example to clarify some things, since syntax and components have changed in Anypoint 3.5 and 3.6.
objectStore-ref
& synchronous=true
attributes of <until-succesful>
are mutually exclusive. This means you can't use the built-in object store feature of <until-succesful>
if you want <until-succesful>
to be synchronous.<processor-chain>
component is deprecated. You should use a <flow-ref>
to call a <sub-flow>
or <flow>
.You can achieve what you want by setting to be synchronous and then manually setting and retrieving values in an objectstore. You have to take a few steps to use the object store, which I will go over below. This is using Anypoint 3.6.
org.mule.util.store.SimpleMemoryObjectStore
). If you are using default memory on ESB or you are deploying to CloudHub, you don't need to do this step. CloudHub uses _defaultUserObjectStore
and the ObjectStore connector defaults to in-memory object store on ESB according to the docs. :)Example config with all this in place:
<mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json"
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" version="EE-3.6.0"
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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.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:listener-config name="HTTP_Listener_Configuration"
host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<!-- Define SimpleMemoryObjectStore as a bean to use. -->
<spring:beans>
<spring:bean id="in.memory.store" name="InMemoryObjectStore"
class="org.mule.util.store.SimpleMemoryObjectStore" />
</spring:beans>
<!-- Configure the object store with the SimpleMemoryObjectStore bean. -->
<objectstore:config name="ObjectStore" doc:name="ObjectStore"
objectStore-ref="in.memory.store" />
<flow name="scratchFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/test" doc:name="HTTP" />
<!-- Set the object store. -->
<objectstore:store config-ref="ObjectStore" key="mydata"
value-ref="#[true]" doc:name="Set store data" />
<until-successful synchronous="true" maxRetries="5"
doc:name="Until Successful">
<flow-ref name="scratchSub_Flow" doc:name="Flow Reference" />
</until-successful>
</flow>
<sub-flow name="scratchSub_Flow">
<!-- Get the data from object store. -->
<objectstore:retrieve config-ref="ObjectStore"
key="mydata" defaultValue-ref="#[false]" doc:name="Get store data" />
<logger level="INFO" doc:name="Logger" message="objectStore value: #[payload]" />
</sub-flow>
</mule>
Upvotes: 1
Reputation: 520
synchronous nature of untill-successful scope doesn't accept object store, the object store configuration is with async nature of untill-successful scope.
save the payload in flow-variable, before the untill-successfull scope and in the untill-successful scope use the set-payload component and set the value from the flowvariable data as a first message process of until-successful scope.
it will work, we are explicitly saving the data and assign the payload for every retry of untill-successful scope. let me know status ones you try.
Upvotes: 0