2013-05-31 126 views
0

我的騾子工作室的版本是: 版本:3.4.0 創建日期:201305141336catch異常策略

我對捕獲異常戰略迷茫......也許我需要使用不同的策略。基本上我需要將數據寫入文件。文件寫入後,我想發送一封電子郵件,指出寫入是否成功。 (如果有人在寫入時打開文件,則最有可能發生故障)。我最初嘗試在catch異常塊中放入一封電子郵件,但接下來發生的事情是我收到了兩封電子郵件;一個在catch塊中,另一個在流程結尾。我試圖創建一個帶有電子郵件主題的變量,並在異常中更改值,但似乎沒有做任何事情。我仍然收到帶有成功信息的電子郵件。

有沒有人有如何使這項工作的一些建議?最終,我只想根據文件寫入成功/失敗發送不同的電子郵件。這是我的配置。通過用鎖定文件的Excel打開目標文件導致失敗。

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

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 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.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd 
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"> 
    <flow name="FileOpenExample" doc:name="FileOpenExample" > 
<quartz:inbound-endpoint xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" jobName="fileOpenEx" cronExpression="0,30 * * ? * FRI" repeatInterval="0" repeatCount="2" responseTimeout="10000" doc:name="Quartz"> 
      <quartz:event-generator-job/> 
     </quartz:inbound-endpoint> 
     <set-payload value="Some Sample File Data" doc:name="Set File Data"/> 
     <set-variable variableName="emailSubject" value="File Save Successful" doc:name="Variable"/> 
     <file:outbound-endpoint path="C:\Temp\IntegrationTesting" outputPattern="Attributes.csv" responseTimeout="10000" doc:name="File"/> 
     <set-payload value="This email was generated by a Mule process." doc:name="Set Email Body"/> 
      <smtp:outbound-endpoint host="mail1.newpig.com" to="${email.toList}" subject="#[emailSubject]" responseTimeout="10000" doc:name="EmailSuccess" /> 
     <catch-exception-strategy doc:name="Catch Exception Strategy" enableNotifications="false"> 
      <expression-transformer expression="#[emailSubject='Save Failed']" doc:name="Expression"/> 
     </catch-exception-strategy> </flow> 
</mule> 

回答

0

這種情況似乎與以前的帖子更類似。

在這裏,流發佈到出站然後繼續流,因爲出站是本質上的異步。需要有一些東西可以讓流程等待,然後根據狀態繼續進行。

你可以在下面的鏈接找到更早的類似帖子和我的答案。

Mule flow execution unexpectedly splits on error in SMTP sendout

希望這有助於。

+0

謝謝。這篇文章讓我走上了正軌。我在這個過程中遇到了其他問題,但這是另一篇文章。 – SteveS