How to addAttachment on Camel 3.0

老子叫甜甜 提交于 2020-04-12 07:10:47

问题


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.


回答1:


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(...)); 


来源:https://stackoverflow.com/questions/59211228/how-to-addattachment-on-camel-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!