可以在Camel中记录简单文本,如下所示
<route>
<from uri="direct:cxlrefdata"/>
<to uri="log:'Hello World'" />
</route>
我想在日志中记录此消息“Hello World”,但我在Apache Camel站点中找到的所有示例都用于记录路由消息。
e.g
<route>
<from uri="direct:t1"/>
<to uri="log:output?showAll=true" />
</route>
我想要一些可以记录测试消息的简单内容。
答案 0 :(得分:7)
是的,请参阅log eip http://camel.apache.org/logeip.html
这允许您将人类可读消息记录到日志中。您可以通过日志组件页面上的绿色提示框发现它:http://camel.apache.org/log
答案 1 :(得分:0)
TL; DR
不要忘记
camel.springboot.main-run-controller=true
中的application.properties
来自(“ timer:// scheduler?fixedRate = true&period = 5s”) .log(“ Hello World!”);
让我为您提供用Java DSL编写的最简单的示例。我将使用Spring Boot Camel启动程序来设置最简单的可运行代码。本示例将帮助您根据Hello World!
组件quartz2
表达式每5秒将消息cron
记录到控制台。
要浏览的文档:
- Spring Boot和Apache Camel-https://camel.apache.org/spring-boot
- 骆驼的Quartz2组件-http://camel.apache.org/quartz2.html
这是您最简单的Spring Boot演示应用程序:
package com.lordnighton.camel.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
这是每5秒将消息HelloWorld!
登录到控制台的最简单的路由:
package com.lordnighton.camel.demo.routes;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class LogMessageRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("quartz2://logMessageGroup/logMessageTimer?cron=0/5+*+*+*+*+?")
.log("Hello World!");
}
}