Reputation: 5755
I am trying to write an Apache Camel route for sending email to myself, based on Part 4 of this tutorial:
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=&[email protected]");
But I'm getting this, and no email in my inbox:
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,
[email protected])), 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=&[email protected]])),
RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]]]))]]
I'm not sure why, or how I can fix this problem. I also seem to be getting these warnings when I run the test:
[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
Upvotes: 3
Views: 18929
Reputation: 7646
The DEBUG and WARN messages can just be ignored.
Following route definition worked for me using Camel v2.12.3:
from("file://target/subfolder")
.log("Working on file ${header.CamelFileName}")
.setHeader("subject", simple("New incident: ${header.CamelFileName}"))
.to("MY_ID@smtp://localhost?password=MY_PASSWORD&[email protected]");
After starting the route, you should see a message such as Working on file XXX
in the log.
Perhaps not the Camel routing is the problem but the SMTP server on localhost. Try to send an email to your SMTP server using another email client and check if you receive any email. An example how to do this using a bash shell on MacOS can be found here.
Please, check if your SMTP server on localhost uses the default port. If not, add the port to the URI such as localhost:MY_PORT
. For SMTP the default is 25
, for SMTPS this is 465
. The active port can be checked using telnet such as telnet SERVERNAME 25
.
The SMTP server may not be the problem but the reading of the files. Check if the files in the target/subfolder
are readable and not locked by Camel, i.e. check if there is no fileName.camelLock
file.
Finally, verify that your route keeps running and doesn't stop before all your files are scanned, see http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html for more information about that.
To summarize my answer: Start small, split large routes into small ones and test them separately.
EDIT: The most recent source code of tutorial-example-reportincident can be found here: https://github.com/apache/camel/tree/master/examples/camel-example-reportincident.
Upvotes: 2