2

in Camel 2.x I could add an Attachment to a Message like:

exchange.getOut().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));

But in Camel 3.0 it is not possible. I change my code like the migration guide says:

exchange.getMessage().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));

But it is not working. Also this not:

exchange.getIn().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));

Have someone an idea, to solve this.

I want to e-Mail this Attachment.

Burner
  • 981
  • 19
  • 41

1 Answers1

10

Camel Version 3 was modularized a lot. So the attachments API was extracted and has to be used differently, see Camel 3 Migration Guide:

The attachments API (javax.activation) has been moved out of org.apache.camel.message into an extension org.apache.camel.attachment.AttachmentMessage from the camel-attachments JAR.

To use this API you can get it via the getMessage method on Exchange:

AttachmentMessage am = exchange.getMessage(AttachmentMessage.class); am.addAttachment("myAtt", new DataHandler(...)); 
hc_dev
  • 8,389
  • 1
  • 26
  • 38
  • More info on the new [Attachments Component](https://camel.apache.org/components/latest/attachments.html) – hc_dev Dec 06 '19 at 16:07