【问题标题】:Mail sending through gmail in Mule Flow在 Mule Flow 中通过 gmail 发送邮件
【发布时间】:2022-01-17 02:33:51
【问题描述】:

我正在努力处理 mule 中的邮件发送流程,出现以下错误:

Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=smtps://dummy.DevGroup:<password>@smtp.gmail.com, connector=SmtpsConnector

我的 xml 文件中有以下配置(使用 Mule XML 中的命名空间声明更新):

<mule
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:twilio="http://www.mulesoft.org/schema/mule/twilio" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
    xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
    xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
    xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
    xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
        http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
        http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.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/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
        http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/3.3/mule-smtp.xsd
        http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd
        http://www.mulesoft.org/schema/mule/twilio http://www.mulesoft.org/schema/mule/twilio/1.0/mule-twilio.xsd">


     <service name="tool.muleservice.emailServiceintegration">
              <inbound>
                    <inbound-endpoint ref="tool.endpoint.emailNotification"/>
              </inbound>
              <outbound>
                <pass-through-router>
                   <outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/>
                </pass-through-router>                              
              </outbound> 
                     
    </service> 
    
    <smtps:endpoint name="tool.smtp.endpoint.emailNotification"                                                           
                          user="#[message.inboundProperties['userName']]"
                          password="#[message.inboundProperties['password']]"
                          host="smtp.gmail.com" 
                          port="465"    
                          from="dummy.DevGroup%40gmail.com"                           
                          transformer-refs="customEmailTransformer"
                          connector-ref="myTSLSMTPConnnector">
    </smtps:endpoint>

    <smtps:connector name="myTSLSMTPConnnector">
        <smtps:tls-client path="../cacerts" storePassword="changeit" />
        <smtps:tls-trust-store path="../cacerts" storePassword="changeit" />
    </smtps:connector>

我将 xml 文件更新为以下内容,以使用给定 here 的 smtp-gmail-connector

<service name="tool.muleservice.emailServiceintegration">
    <inbound>
        <inbound-endpoint
            ref="tool.endpoint.emailNotification" />
    </inbound>
    <outbound>
        <pass-through-router>
            <!-- <outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/> -->
            <smtp:outbound-endpoint connector-ref="smtpGmailConnector"
                 subject="test msg"
                address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]@smtp.gmail.com"
                responseTimeout="10000" doc:name="Send notification email" />
        </pass-through-router>
    </outbound>

</service> 
<smtp:gmail-connector name="smtpGmailConnector"
    contentType="text/html" fromAddress="iip.claims.test@gmail.com"
    replyToAddresses="iip.claims.test@gmail.com" >
    <smtp:header key="foo" value="bar" />
    <smtp:header key="baz" value="boz" />
</smtp:gmail-connector>

但在此之后我收到以下错误:

 Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-component-config/component-config.xml]
Offending resource: mule-bootstrap-config.xml; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-mule-bootstrap-config.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-component-config/component-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-intrg-flows.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-mule-bootstrap-config.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 91 in XML document from URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-intrg-flows.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 91; columnNumber: 67; The prefix "doc" for attribute "doc:name" associated with an element type "smtp:outbound-endpoint" is not bound.
    at deployment.myApp.war//org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
    at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at deployment.myApp.war//org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:235)

任何帮助将不胜感激。

【问题讨论】:

  • &lt;service&gt; 语法。多年来从未见过,也从未在实际应用中看到过。这是在哪个版本的 Mule 中部署的?
  • 是Mule 3.9版本。
  • 是否有理由使用已弃用的&lt;service&gt; 定义?我相信文档中不再提到这一点。您链接到的示例直接使用流。此外,您没有提到部署是嵌入到 JBoss 7.2 服务器中的(从我在日志中看到的)。您应该在 Mule XML 中提供有关构建 (pom.xml) 和命名空间声明的更多详细信息。此信息相关的原因是它们可能导致与所述错误相关的问题。如果你只是重建现有的应用程序而不添加 GMail 支持,它可以工作吗?

标签: smtp gmail mule smtps


【解决方案1】:

但是在重新阅读问题时缺少许多细节,我怀疑您没有通过尝试使用当前示例正确遵循已弃用的语法 &lt;service&gt;。由于该语法已被弃用 6 年多,我建议改用更新的 &lt;flow&gt; 定义。

如果您无法或不愿意迁移,您需要在服务之外定义一个端点并引用它,您可以尝试以下步骤:

  1. 确保文件开头的命名空间是正确的。该错误提到无法识别doc:。也许命名空间已经过时了。
  2. 确保 pom 中的依赖项引用您的 Mule 3.9.x 版本,而不是可能未定义文档的旧版本。
  3. 尝试将 &lt;smtp:outbound-endpoint&gt; 移动到单独的端点定义,并从 &lt;pass-through-router&gt; 中引用它,就像在您的原始实现中一样。

例子:

 <service name="tool.muleservice.emailServiceintegration">
              <inbound>
                    <inbound-endpoint ref="tool.endpoint.emailNotification"/>
              </inbound>
              <outbound>
                <pass-through-router>
                   <outbound-endpoint ref="tool.smtp.endpoint.gmailNotification"/>
                </pass-through-router>                              
              </outbound> 
                     
    </service> 
    
    <smtps:endpoint name="tool.smtp.endpoint.gmailNotification"                                                           
                         connector-ref="smtpGmailConnector"
                 subject="test msg"
                address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]@smtp.gmail.com"
                responseTimeout="10000" doc:name="Send notification email" >
    </smtps:endpoint>


<smtp:gmail-connector name="smtpGmailConnector"
    contentType="text/html" fromAddress="iip.claims.test@gmail.com"
    replyToAddresses="iip.claims.test@gmail.com" >
    <smtp:header key="foo" value="bar" />
    <smtp:header key="baz" value="boz" />
</smtp:gmail-connector>

最后,如果一切都失败了,您可以尝试删除 doc:name 属性,看看会发生什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-31
    • 2018-11-13
    • 2012-01-07
    • 2023-03-19
    • 2017-09-20
    • 2012-05-22
    相关资源
    最近更新 更多