0

我正在努力处理 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 文件更新为以下内容,以使用此处给出的 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)

任何帮助将不胜感激。

4

1 回答 1

0

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

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

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

例子:

 <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属性,看看会发生什么。

于 2021-12-14T17:34:30.797 回答