1
FTP를 통해 파일을 다운로드하는 경로가 있습니다. 그 후 나는 파일명을 jms : queue에 보내고 싶지 않다. 그걸하기 위해 호? Apache Camel - 처리 할 파일 이름
는 사실은 내가 processFileNameToBody (org.apache.camel.Processor)이이 경로<from uri="ftp://ftp.x.com?username=x&password=x&binary=true&stepwise=false&delay=20000" />
<to uri="file://{{download_folder}}?fileName=${date:file:yyyyMMdd}_${file:name}&keepLastModified=true" />
<to uri="processFileNameToBody" />
<to uri="jms:queue:File.Process" />
public void process(Exchange exchange) throws Exception {
try {
if (exchange.getIn() instanceof GenericFileMessage) {
log.info("Starting Processing FileName to body");
Map<String, String> map = new HashMap<String, String>();
String file = (String) exchange.getIn().getHeader("CamelFileNameProduced");
map.put("file", file);
XStream xs = new XStream();
String xml = xs.toXML(map);
exchange.getOut().setBody(xml);
log.info("Finished Processing FileName to body:" + file);
}
}
catch (Exception e) {
log.error("", e);
throw e;
}
}
을 가지고 있지만 그것은 작동하지 않습니다. 나는 아마도 누군가가 이것에 대한 솔루션을
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: RemoteFile[
GenericFileConverter.convert.to
에서 NPE를 얻었다. 그것은 그렇게 복잡 할 수는 없지만 실제로는 실패합니다. 파일이 작성 될 때해야 할 일이 있다고 생각합니다. 끝에 writte이지만, 나는 시체를 이미 바꾸었다.도움을 주시면 감사하겠습니다. 감사합니다
가 대단히 감사합니다. 그거야. 그런데 왜 그 솔루션이 내 프로세스와 다른가요?일까요? 아니면 정확히 차이가 있습니까? –
xyx
글쎄, 당신의 프로세서에서 왜 모든 XML 작업을하고 있는지 잘 모르겠습니다. 그러나 동일한 작업을 수행하려면 'exchange.getIn(). setBody (String) exchange.getIn(). getHeader ("CamelFileNameProduced"))'를 수행해야합니다. 낙타의 문서에서 In과 Out에 대해 더 자세히 읽어보십시오 :) – hveiga
xml 자료는 나중의 프로세스 용이었습니다. 그런 다음 jms로 보내는 것이 더 쉬워졌습니다. 나는 지금 그것을 길에서 직접한다. 고맙습니다. – xyx