【发布时间】:2014-06-11 11:17:58
【问题描述】:
我正在尝试根据本教程的第 4 部分编写一个用于向自己发送电子邮件的 Apache Camel 路由:
https://camel.apache.org/tutorial-example-reportincident.html
from("file://target/subfolder")
.setHeader("subject", constant("new incident reported"))
.convertBodyTo(String.class)
// send the email
.to("smtp://myID@localhost?password=&to=myname@mycompany.com");
但我收到了这个,但我的收件箱中没有电子邮件:
395 [main] DEBUG org.apache.camel.example.reportincident.
ReportIncidentRoutesTest - Routing Rules are:
[EventDrivenConsumerRoute[Endpoint[direct:start] ->
Delegate(Delegate(Pipeline[DeadLetterChannel[Delegate(setHeader(org.apache.
camel.file.name, BeanExpression[bean:org.apache.camel.example.reportincident.
FilenameGenerator@244aeb52 method: generateFilename])),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]],
DeadLetterChannel[Delegate(sendTo(Endpoint[velocity:MailBody.vm])),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]],
DeadLetterChannel[Delegate(sendTo(Endpoint[file://target/subfolder])),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]]]))],
EventDrivenConsumerRoute[Endpoint[file://target/subfolder] ->
Delegate(Delegate(Pipeline[DeadLetterChannel[Delegate(setHeader(To,
myname@mycompany.com)), RecipientList[log:org.apache.camel.DeadLetterChannel?
level=error]], DeadLetterChannel[Delegate(setHeader(subject, new incident
reported)), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]],
DeadLetterChannel[Delegate(org.apache.camel.processor.
ConvertBodyProcessor@6e79839),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]],
DeadLetterChannel[Delegate(sendTo(Endpoint[smtp://myID@localhost?
password=&to=myname@mycompany.com])),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]]]))]]
我不知道为什么,也不知道如何解决这个问题。当我运行测试时,我似乎也收到了这些警告:
[WARNING] The POM for com.sun.xml.fastinfoset:FastInfoset:jar:1.2.2 is invalid,
transitive dependencies (if any) will not be available,
enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.1.7 is invalid,
transitive dependencies (if any) will not be available,
enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.1.7 is invalid,
transitive dependencies (if any) will not be available,
enable debug logging for more details
...
606 [main] WARN org.apache.camel.impl.converter.DefaultTypeConverter -
Overriding type converter from: StaticMethodTypeConverter:
public static java.lang.String org.apache.camel.converter.IOConverter.
toString(javax.xml.transform.Source) throws javax.xml.transform.
TransformerException,java.io.IOException to: InstanceMethodTypeConverter: public
java.lang.String org.apache.camel.converter.jaxp.XmlConverter.toString
(javax.xml.transform.Source) throws javax.xml.transform.TransformerException
【问题讨论】:
-
你在使用什么类型的文件?
-
您是否使用任何自定义类型转换器?
-
警告信息是无害的。您可能需要检查是否有任何其他警告或错误消息。
-
回答问题:(1) 文件类型为.vm。 (2) 我认为没有任何自定义类型转换器。 (3) 我没有看到任何其他警告或错误消息。
-
首先,尝试发送常规文本文件而不是 Velocity 模板。或许,Camel 试图施展魔法。
标签: java routing smtp apache-camel