简体   繁体   English

Apache Camel with Spring Boot - Zip 进程

[英]Apache Camel with Spring Boot - Zip process

I am trying to process a zip file with Apache Camel.我正在尝试使用 Apache Camel 处理 zip 文件。 After making a call, I get a zip file and try to prepare the next call with this zip file as body.拨打电话后,我得到一个 zip 文件,并尝试以这个 zip 文件为正文准备下一次通话。 The call requires a form data with one name and zip file as value.该调用需要一个具有一个名称和 zip 文件作为值的表单数据。 I handle in this way:我是这样处理的:

process(e ->{
                    Object zip = e.getIn().getBody();                        
                    MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
                    body.add("file",zip);
                    e.getIn().setBody(body);
                })

But I receive the exception:但我收到异常:

org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.springframework.util.LinkedMultiValueMap to the required type: java.io.InputStream with value {file=[[B@2b02c691]}

Any Ideas?有任何想法吗?

Cheers!干杯!

I tried to get the response in byte[] but it still dose not work.我试图在 byte[] 中获得响应,但它仍然不起作用。

As Jeremy said, the error says Camel is expecting (further in the process) a body of type InputStream , whilst you are obviously preparing a body of type MultiValueMap (BTW: why use a map if you have a single object to handle??)正如 Jeremy 所说,该错误表明 Camel 期望(在此过程中进一步)类型为InputStream的主体,而您显然正在准备类型为MultiValueMap的主体(顺便说一句:如果您要处理单个object,为什么要使用 map??)

I do not know what is the concrete type of your 'zip' object, but (if needed) you may have to replace current body with its inputstream equivalent:我不知道你的 'zip' object 的具体类型是什么,但是(如果需要)你可能必须用它的等效输入流替换当前主体:

process(e ->{
   // Print concrete type
   Object zip = e.getMessage().getBody(); 
   System.out.println("Type is " + zip.getClass() );
   // Convert body
   InputStream is = e.getMessage().getBody(InputStream.class); 
   // Replace body                       
   e.getMessage().setBody(is);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM