【问题标题】:Sending detailed email of exception in Mule ESB using SMTP connector使用 SMTP 连接器在 Mule ESB 中发送详细的异常电子邮件
【发布时间】:2015-05-27 17:38:49
【问题描述】:

我的流程中有一个“捕获异常策略”,我使用 SMTP 连接器向管理员(我)发送电子邮件。

我可以使用#[exception] 发送异常,但我想发送更详细的消息,包括:

  • 完整的 URL 请求
  • 发送的原始负载
  • 转换后的有效载荷
  • (可选,但很好)完整的堆栈跟踪和错误发生时间,如控制台中。

我尝试使用表达式组件和变量来存储这些信息。我也尝试过使用变量组件,但这也不起作用。我的所有变量在消息中始终设置为 null。

这是我的流程:

    <flow name="PivotalContactById" >
                <https:inbound-endpoint connector-ref="HTTP_HTTPS" exchange-pattern="request-response" host="host" port="port" doc:name="HTTP (Deprecated)" path="path"/>
                <logger level="INFO" message="#[message.payloadAs(java.lang.String)]" doc:name="Logger"/>
            <set-variable variableName="flowVars.url" value="#[message.inboundProperties.'http.context.url']" doc:name="Variable"/>
            <set-variable variableName="flowVars.originalPayload" value="#[payload]" doc:name="Variable"/>
                <json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
                <scripting:component doc:name="GroovyContactIDJsonToXML">
                    <scripting:script engine="Groovy" file="pivotalContactById_JSON_to_XML.groovy"></scripting:script>
                </scripting:component>
                <logger level="INFO" message="#[message.payloadAs(java.lang.String)]" doc:name="Logger"/>
            <set-variable variableName="flowVars.convertedPayload" value="#[payload]" doc:name="Variable"/>
                <ws:consumer config-ref="Web_Service_Consumer1" operation="GetContactById" doc:name="Pivotal SOAP Web Service"/>
                <logger level="INFO" message="#[message.payloadAs(java.lang.String)]" doc:name="Logger"/>
            <catch-exception-strategy doc:name="Catch Exception Strategy">
                <set-payload value="#[exception] #[flowVars.url] #[flowVars.originalPayload] #[flowVars.convertedPayload]" doc:name="Set Payload"/>
            <smtp:outbound-endpoint host="host" to="dude@dude.org" from="adminmule@dude.org" subject="Exception yo" responseTimeout="10000" doc:name="SMTP"/>
            </catch-exception-strategy>
</flow>

【问题讨论】:

  • 在流级别设置时单独提供 VariableName=url(不是 flowVars.url)。当您在设置为 #[flowVars.url] 或 #[flowVars['url']] 的 Catch Exception Strategy 中访问它时。试试这个。
  • 这似乎工作谢谢!您介意将其发布为答案以便我接受吗?
  • 太好了,成功了!!

标签: xml mule mule-el


【解决方案1】:

在flow Level中,请单独提供variableName = url(不是flowVars.url)。在设置为#[flowVars.url]#[flowVars['url']] 的Catch Exception Strategy 中访问它时。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    相关资源
    最近更新 更多