如何在 Camel 3.0 上添加附件
How to addAttachment on Camel 3.0
在 Camel 中 2.x 我可以在消息中添加附件,例如:
exchange.getOut().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
但在 Camel 3.0 中这是不可能的。我按照迁移指南中的说明更改了我的代码:
exchange.getMessage().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
但它不起作用。这也不是:
exchange.getIn().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
请教解决这个问题的想法。
我想通过电子邮件发送此附件。
Camel 版本 3 进行了很多模块化。所以 附件 API 被提取出来并且必须以不同的方式使用,参见 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(...));
在 Camel 中 2.x 我可以在消息中添加附件,例如:
exchange.getOut().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
但在 Camel 3.0 中这是不可能的。我按照迁移指南中的说明更改了我的代码:
exchange.getMessage().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
但它不起作用。这也不是:
exchange.getIn().addAttachment("LogFile.log.gz", new DataHandler(Base64.decodeBase64(FileContentBase64),"application/x-gzip"));
请教解决这个问题的想法。
我想通过电子邮件发送此附件。
Camel 版本 3 进行了很多模块化。所以 附件 API 被提取出来并且必须以不同的方式使用,参见 Camel 3 Migration Guide:
The attachments API (javax.activation) has been moved out of
org.apache.camel.message
into an extensionorg.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(...));