0

I've googled a significant amount on this, and I'm fairly comfortable with JBoss ESB and Camel.

I've defined a Camel Mail endpoint, and my goal is to extract attachments from emails for the purpose of using them for content-based routing.

The Camel integration in JB ESB is a bit of a black box, but basically, the body content of the email is ending up on the message body in the default location as a String. If it's a plaintext or HTML email, this is fine and I can work with it. But if there are multiple attachments, Camel will provide a javax.mail.internet.MimeMultiPart (which is fine)

The problem is that JBoss ESB is trying to "force" this to a String, or so it seems, because the message body default location is literally a string object with the value of e.g. javax.mail.internet.MimeMultipart@100600 When I try to cast the body to a mimeMultipart,via javax.mail.internet.MimeMultipart mime= (MimeMultipart)message.getBody().get();, I get the predictable exception java.lang.ClassCastException: java.lang.String cannot be cast to javax.mail.internet.MimeMultipart

How do I access the different parts of a MIME Multipart message that was inbounded into JBoss ESB using camel mail?

many thanks, AGM

Camel-Mail 2.10

Jboss ESB 5.3.1

Windows Environment

Replicated on colleague's machine

10:39:54,808 INFO  [STDOUT] Body Name is org.jboss.soa.esb.message.defaultEntry
10:39:54,809 INFO  [STDOUT] Body Class is class java.lang.String
10:39:54,809 INFO  [STDOUT] Attempting to display body contents via toString
10:39:54,809 INFO  [STDOUT] body value is javax.mail.internet.MimeMultipart@150ce1d
10:39:54,809 INFO  [STDOUT] javax.mail.internet.MimeMultipart@150ce1d
10:39:54,809 INFO  [STDOUT] class java.lang.String
10:39:54,809 INFO  [STDOUT] class java.lang.String
10:39:54,810 ERROR [STDERR] java.lang.ClassCastException: java.lang.String cannot be cast to javax.mail.internet.MimeMultipart
10:39:54,810 ERROR [STDERR]     at com.XXX.integration.actions.GetAttachment.process(GetAttachment.java:23)
10:39:54,810 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:667)
10:39:54,810 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:614)
10:39:54,811 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:442)
10:39:54,811 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:587)
10:39:54,811 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
10:39:54,811 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
10:39:54,812 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:662)
10:39:54,812 INFO  [STDOUT] FULL SPOOL:
  • Always tell what version of the various projects you use, as its important information. – Claus Ibsen Jun 05 '13 at 08:43
  • I've also tried extending CamelMessageComposer and trying to inject that using property "composer-class" but the ESB doesn't seem to honor the injection attempt (not seeing first-line printlns) – user2453070 Jun 05 '13 at 15:35

1 Answers1

1

Configure mapMailMessage=false, then you can access the source MailMessage API from the JavaMail API and you can grab the data yourself.

See details at the Camel doc: http://camel.apache.org/mail.html

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Thanks for the advice. I've tried this, but it doesn't seem to change anything. Body is still an actual string that contains the class type and memory reference... as a string... – user2453070 Jun 05 '13 at 14:41
  • No, you can grab the raw original MailMessage API from the JDK. There you can do you own parsing of the data, eg when you set that option - Camel does NOT touch the mail message at all. – Claus Ibsen Jun 05 '13 at 15:58
  • javax.mail.Message msg = exchange.getIn(MailMessage.class).getMessage(); – Claus Ibsen Jun 05 '13 at 16:02