[JDK 8/11, Camel 2.23.1, Spring Boot 2.1.3]
Привет, сейчас я изучаю Camel и не могу преодолеть странную проблему.
Я хочу загрузить URL в файл.
URL работает, например, http://localhost/date показывает «11:59:00».Целевой файл создан, но он пуст.Почему?
@Component
public class DownloadRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
String timer1 = "timer://foo?fixedRate=true&period=10000&delay=5000";
String url = "http://localhost:8888/date";
String file = "file:target/date";
from(timer1).to(url).log("${id}->${body}").to(file); // ID-Laptop-1551464093962-0-2->11:59:00, that's ok
}
}
Регистратор выводит правильное содержимое, например,
2019-03-01 19: 15: 00.421 INFO 2984 --- [3 - timer: //foo] route1
: ID-Laptop-1551464093962-0-2-> 11: 59: 00
, но сгенерированный файл (например, target / date / ID-Laptop-1551464093962-0-2) пусто.
Есть идеи?
Решение (спасибо Тахе):
from(timer1).to(url).to(file); // without logging
ИЛИ
from(timer1).to(url).convertBodyTo(String.class).log("${id}->${body}").to(file); // with logging