2013-02-22 2 views
0

click hear to see my flow ImageMule Studio 글로벌 변수를 만드는 방법

내 테스트 뮬 응용 프로그램. 내가는 HTTP 엔드 포인트에 컬 JSON 포스트 데이터를 사용하여 객체와 I가 캐치 예외 전략을 사용하는 이름 (# [message.payload.name])

내 데이터베이스에 삽입 할 JSON tranforms 업데이트를 의미하는 것은 FIRSTNAME = # [message.payload.name]

설정 MYTABLE - 오류 로그 (경우 고유 이름) I 필드에서 # [message.payload.name] 을 조건으로 내 테이블을 업데이트 할

을 유지 catch-exception-strategy에서 # [message.payload.name]에 액세스 할 수 없습니다.

전역 변수의 일종을 갖고 싶어 제목을 바탕으로 내 구성

<?xml version="1.0" encoding="UTF-8"?> 

<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" 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.3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" 
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/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd 
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.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 "> 
    <data-mapper:config name="Mapper" transformationGraphPath="mapper.grf" doc:name="DataMapper"></data-mapper:config> 
    <jdbc-ee:mysql-data-source name="MySQL_Data_Source1" url="jdbc:mysql://localhost:3306/mule" user="root" password="1234" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source"/> 
    <jdbc-ee:connector name="Database" dataSource-ref="MySQL_Data_Source1" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/> 
    <flow name="httpPostTestFlow1" doc:name="httpPostTestFlow1"> 
     <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="httpPost" doc:name="httpPost"></http:inbound-endpoint> 

     <json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Map"></json:json-to-object-transformer> 


       <jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="INSERT_TOKEN" connector-ref="Database" doc:name="Database"> 
        <jdbc-ee:query key="INSERT_TOKEN" value="insert into users(FirstName) values(#[message.payload.name]);"/> 
       </jdbc-ee:outbound-endpoint> 


       <!-- <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="80" path="post-debug.php" contentType="application/x-www-form-urlencoded" doc:name="post-debug.php"/> --> 


     <catch-exception-strategy doc:name="Catch Exception Strategy"> 
      <expression-component doc:name="Create error response">#[message.payload = "{\"status\":\"error\", \"message\":\"" + exception.cause.message + "\"}"]</expression-component> 
      <jdbc-ee:outbound-endpoint exchange-pattern="one-way" connector-ref="Database" doc:name="Database" queryTimeout="-1" queryKey="UPDATE_TOKEN"> 
        <jdbc-ee:query key="UPDATE_TOKEN" value="update users SET fail_message = #[message.payload]"/> 
       </jdbc-ee:outbound-endpoint> 
     </catch-exception-strategy> 


    </flow> 
</mule> 

답변

0

, 하나의 방법은 빠른 수정으로 flowVars를 사용하여 시도 할 수있다. Mule Studio를 사용하면 Variable (변압기 아래)과 동일합니다.

catch 예외 전략에 포함 된 메시지는 예외입니다.

+0

문서가 적어서 고맙습니다. –