我创建了一个处理器来从外部源下载一些文件。
我这样做,就像这样:
CamelContext context = exchange.getContext();
ProducerTemplate template=context.createProducerTemplate();
Object answer=null;
try {
answer=template.requestBodyAndHeaders(
uri,
"",
headers);
} catch (Exception e) {
....
} finally {
template.stop();
}
if (answer != null) {
/* Here I need to know, if it is a file, or an error-message */
}
问题是,请求可以是错误消息(字符串),也可以是流(找到文件时)。
如何检查?
感谢您的帮助
更新:
路线代码很简单:
from("http://domain.de/getDoc?Id=123")
to("file:docs")
最佳答案
也许只是“instanceof”检查会有帮助?
关于java - 如何判断camel中的交换Body属于哪种类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42807958/