【问题标题】:Apache Camel smtp component hangs the whole bus if mailserver is down如果邮件服务器关闭,Apache Camel smtp 组件会挂起整个总线
【发布时间】:2011-10-29 18:34:09
【问题描述】:

我有一个我认为很常见的情况。我有一个通过 Apache Camel 管理的发票系统。当出现问题时,我希望向管理员发送电子邮件警报。

在阅读了有关 Camel 异常处理的内容后,我想到了这个:(在我的 Spring XML 中)

<!-- General retrasmission policy set to 3 times -->
        <errorHandler id="deadChannel" type="DeadLetterChannel"
            deadLetterUri="direct:invoice-error">
            <redeliveryPolicy maximumRedeliveries="2"
                redeliveryDelay="1000" backOffMultiplier="2" useExponentialBackOff="true" />
        </errorHandler>

        <!-- Problematic invoices create email alerts to the administrator -->
        <route id="invoices-with-errors">
            <from uri="direct:invoice-error" />
            <bean ref="emailAlert" method="handleProblematicInvoice" />
            <to
                uri="smtp://{{errormail.host}}?to={{errormail.to}}&amp;subject={{errormail.subject}}&amp;from={{errormail.from}};debugMode=true;connectionTimeout=5000" />
        </route>

这适用于我的用例OK。当抛出任何异常时,会发送一封电子邮件 确实到了定义的地址。

但是,为了测试极端情况,我停止了内部电子邮件服务器以查看 发生。我希望 Camel 尝试发送电子邮件并在 5 秒后停止尝试(如上面 smpt URL 中的 connectionTimout 选项中设置的那样)

实际上,整个 Camel 应用程序挂起!这简直不能接受! 我不能保证邮件服务器会 100% 运行。

我在这里遗漏了什么吗?我应该完全放弃电子邮件警报的想法,还是 Camel 需要另一个特殊选项来在邮件服务器关闭时挂起?

回答

线

debugMode=true;connectionTimeout=5000 

应该是

debugMode=true&amp;connectionTimeout=5000

【问题讨论】:

  • 设置 localhost SMTP 假脱机以中继到主内部服务器?
  • @Steve-o Ι 无权访问生产。我只能将 .war 文件发送给 IT 服务,然后他们进行部署。我不能给他们发其他任何东西。

标签: java exception-handling smtp apache-camel reliability


【解决方案1】:

Camel 使用 Java 邮件 API,因此发送一封电子邮件或找出问题所在需要多长时间。

您可以使用wireTap 异步发送电子邮件。然后错误处理程序线程不会出现更长的阻塞时间 http://camel.apache.org/wire-tap

【讨论】:

  • 好的。但是connectionTimout不应该工作吗?现在它永远阻塞了。此外,如果我使用窃听并且邮件服务器已关闭,则会引发异常并且错误处理程序路由将再次启动,导致无限循环。对吗?
  • 如果您正在执行错误处理,错误处理程序将不会再次启动。这在 Camel 2.8 中得到了进一步的改进。如果发生第二个异常,则会使用描述性错误消息设置包装异常。
  • 另外你的连接超时选项是错误的,你需要使用 & 字符。 debugMode=true;connectionTimeout=5000 应该是 debugMode=true&connectionTimeout=5000
猜你喜欢
  • 2013-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-29
  • 1970-01-01
  • 1970-01-01
  • 2011-12-14
  • 1970-01-01
相关资源
最近更新 更多