m子:文件传输m子流中的异常处理



i具有简单的m子配置,该配置为HTTP查询参数,构建URL&从URL下载文件。它没什么大不了的&不使用任何类型的文件(或FTP/SFTP)协议。为此,我需要考虑什么样的例外处理机制?

这是代码的片段:

 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8048" doc:name="HTTP Listener Configuration"/>
 <http:request-config name="HTTP_Request_Configuration" host="${sync.host}" port="${sync.port}" doc:name="HTTP Request Configuration"/>
 <file:connector name="output" doc:name="File"/>

 <flow name="syncFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/og" allowedMethods="GET" doc:name="HTTP"/>
    <set-variable variableName="year" value="#[message.inboundProperties.'http.query.params'.year]" doc:name="Variable"/>     
    <set-variable variableName="month" value="#[message.inboundProperties.'http.query.params'.month]" doc:name="Variable"/>
    <http:request config-ref="HTTP_Request_Configuration" path= "/year/{year}/month/{month}/monthly.csv" method="GET" doc:name="HTTP">   
       <http:request-builder>
          <http:uri-param paramName="year" value="#[flowVars.year]"/> 
          <http:uri-param paramName="month" value="#[flowVars.month]"/>
       </http:request-builder> 
    </http:request> 

这也是流程的末端&amp;我只是简单地抛弃了我收到的文件,有关处理此部分的优雅方法的任何建议?

我需要考虑什么样的例外处理机制 这个?

我将使用选择例外策略来捕获与文件权限,磁盘空间和已经存在的文件有关的例外。

关于处理该代码的这一部分的优雅方法的任何建议?

,如果您不愿重复使用它们,而只是将值直接放入请求构建器中,则可能会删除变量声明。您还可以使用调用范围将它们折叠成一个"消息属性"变压器。

我需要考虑什么样的例外处理机制 这个?

,如果您要发送请求的服务已下降或未能正确接收您的请求,则可以拥有Rollback Exception Strategy

最新更新