6
Basic Example Using Until Successful Component

Basic example using until successful component

Embed Size (px)

Citation preview

Page 1: Basic example using until successful component

Basic Example Using Until Successful Component

Page 2: Basic example using until successful component

Introduction

The until-successful scope processes messages through the processors within it until the process succeeds. By default, until-successful’s processing occurs asynchronously from the main flow. After passing a message into the until-successful scope, the main flow immediately regains control of the thread. However, you can configure until-successful to run synchronously relative to the main flow.

Page 3: Basic example using until successful component

FLOW

FLOW:

Page 4: Basic example using until successful component

XML:<?xml version="1.0" encoding="UTF-8"?><mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" 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" version="EE-3.4.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.xsdhttp://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsdhttp://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsdhttp://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsdhttp://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd"> <jdbc-ee:mssql-data-source name="MS_SQL_Data_Source" user=“****" password=“****" url="jdbc:sqlserver://localhost;databaseName=test1" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data Source"/> <jdbc-ee:connector name="Database" dataSource-ref="MS_SQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/> <spring:beans> <spring:bean id="Bean" name="Bean" class="org.mule.util.store.SimpleMemoryObjectStore"/> </spring:beans> <flow name="Database_ComponentFlow2" doc:name="Database_ComponentFlow2"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="US" doc:name="HTTP"/> <logger message="--main flow--" level="INFO" doc:name="Logger"/> <expression-component doc:name="Expression"><![CDATA[ sessionVars['DB_STATUS']='INITIAL'; ]]></expression-component> <until-successful objectStore-ref="Bean" maxRetries="5" secondsBetweenRetries="5" doc:name="Until Successful" failureExpression="#[sessionVars['DB_STATUS']!='SUCCESS']"> <vm:outbound-endpoint exchange-pattern="request-response" path="db" doc:name="VM"/> </until-successful> </flow> <flow name="Database_ComponentFlow3" doc:name="Database_ComponentFlow3"> <vm:inbound-endpoint exchange-pattern="request-response" path="db" doc:name="VM"/> <jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="select" queryTimeout="-1" connector-ref="Database" doc:name="Database"> <jdbc-ee:query key="select" value="select * from mytable1"/> </jdbc-ee:outbound-endpoint> <expression-component doc:name="Expression"><![CDATA[ sessionVars['DB_STATUS']='SUCCESS'; ]]></expression-component> <logger message="--success" level="INFO" doc:name="Logger"/> </flow></mule>

Page 5: Basic example using until successful component

Execution:URL to trigger the service from browserhttp://localhost:8080/US Database component connects to the specific database, executes the select query but there is no table specified in DB, hence the until successful component retries for 5 times and exit the flow.