3

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=&to=myname@mycompany.com");

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, 
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]]]))]]

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
La-comadreja
  • 5,627
  • 11
  • 36
  • 64

1 Answers1

2

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&to=myname@mycompany.com"); 

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.

Community
  • 1
  • 1
Peter Keller
  • 7,526
  • 2
  • 26
  • 29
  • doesn't recognize method log() and the smtp:// was the correct endpoint. Camel version is 1.5.0 – La-comadreja Apr 28 '14 at 14:53
  • @La-comadreja The `log` EIP was introduced in Camel v2.2 (see https://camel.apache.org/logeip.html). I would highly recommend to upgrade to the latest version 2.12.3. – Peter Keller Apr 28 '14 at 15:05
  • the problem is that I am going through a tutorial written in an older version. – La-comadreja Apr 28 '14 at 15:05
  • 1
    @La-comadreja Use a more recent tutorial...? – Peter Keller Apr 28 '14 at 15:07
  • It's Apache's. I'm about to edit the question to show more info – La-comadreja Apr 28 '14 at 15:08
  • @La-comadreja Try to update the Maven dependencies to the latest Camel version and check if it works. – Peter Keller Apr 28 '14 at 15:14
  • doesn't work for 2.12, the names of what I'm using are older. – La-comadreja Apr 28 '14 at 15:16
  • When I try to change to 2.12, error I'm getting is Could not resolve dependencies for project org.apache.camel:camel-example-reportincident:war:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.camel:camel-core:jar:2.12.0: Failed to read artifact descriptor for org.apache.camel:camel-core:jar:2.12.0 – La-comadreja Apr 28 '14 at 15:20
  • @La-comadreja Please use `2.12.3` and not `2.12` or `2.12.0` – Peter Keller Apr 28 '14 at 15:22
  • 2.12.3 gives this error: :camel-example-reportincident:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.apache.camel:camel-core:jar:2.12.3, org.apache.camel:camel-mail:jar:2.12.3, org.apache.camel:camel-velocity:jar:2.12.3, org.apache.camel:camel-spring:jar:2.12.3, org.apache.camel:camel-cxf:jar:2.12.3: Could not find artifact org.apache.camel:camel-core:jar:2.12.3 in central-local – La-comadreja Apr 28 '14 at 15:27
  • @La-comadreja That's strange. Check if you have access to the Maven repository, see http://mvnrepository.com/artifact/org.apache.camel/camel-core/2.12.3 – Peter Keller Apr 28 '14 at 15:35
  • On my computer yes, but it also says Could not find artifact org.apache.camel:camel-core:jar:2.12.3 in central-local – La-comadreja Apr 28 '14 at 15:42
  • Full error includes ...Could not resolve dependencies for project org.apache.camel:camel-example-reportincident:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.apache.camel:camel-core:jar:2.12.3, org.apache.camel:camel-mail:jar:2.12.3, org.apache.camel:camel-velocity:jar:2.12.3, org.apache.camel:camel-spring:jar:2.12.3, org.apache.camel:camel-cxf:jar:2.12.3: Failure to find org.apache.camel:camel-core:jar:2.12.3 in http://MKTDEVPC3386:8081/artifactory/libs-release-local was cached in the local repository, resolution will not be reattempted... – La-comadreja Apr 28 '14 at 15:44
  • 1
    @La-comadreja Your local Maven may be broken. See http://stackoverflow.com/questions/4856307/when-maven-says-resolution-will-not-be-reattempted-until-the-update-interval-of. Solve this issue by deleting the corresponding failed download artifact directory in your local repo. – Peter Keller Apr 28 '14 at 15:49
  • same compiler error when I try to add "Always" to my settings file and -U to $mvn command. Still at it. – La-comadreja Apr 28 '14 at 16:01
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/51616/discussion-between-la-comadreja-and-peter) – La-comadreja Apr 28 '14 at 17:25
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/51774/discussion-between-la-comadreja-and-peter) – La-comadreja Apr 30 '14 at 18:59
  • @La-comadreja Could you finally solve your problem? You never accepted the answer... – Peter Keller May 23 '14 at 07:05
  • Thank you for asking @Peter. Actually, I couldn't email myself and moved on from this. – La-comadreja May 23 '14 at 13:47