You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Josiah Mangiameli <jo...@urjanet.com> on 2013/05/14 04:03:41 UTC
Using CamelContextHelper the DataHandler cannot getInputStream
Hey All,
I am seeing some unexpected behaviour when using the CamelContextHelper.
I am using the CamelContextHelper to generate an endpoint and receive an
exchange. The exchange is an email message with a normal pdf attached.
However when I attempt to get the Input Stream from the attachment I get
a file IO Exception.
I am not calling: "consumerTemplate.doneUoW(exchange);" until after the
exchange (and attachment) is done being processed. I was not having this
problem when I used RouteBuilder to get my exchange.
Here is the relevant section of my code:
Endpoint endpoint =
CamelContextHelper.getMandatoryEndpoint(camelContext, route);
Exchange exchange = consumerTemplate.receive(endpoint, 5000);
Object body = exchange.getIn().getBody();
if (body instanceof MimeMultipart){
Map<String, DataHandler> attachments =
exchange.getIn().getAttachments();
if (attachments.size() > 0) {
for (String name : attachments.keySet()) {
DataHandler dh = attachments.get(name);
processFile(dh.getInputStream(),dh.getName());
}
}
}
Regards,
--
Josiah Mangiameli
Software Developer
Urjanet Energy Solutions
(770) 262 9306