Register plain text in Apache Camel logs

Is it possible to write plain text in Camel as follows

<route> <from uri="direct:cxlrefdata"/> <to uri="log:'Hello World'" /> </route> 

I want to write this "Hello World" message in a log, but all the examples I found on the Apache Camel website are for logging route messages.

eg

 <route> <from uri="direct:t1"/> <to uri="log:output?showAll=true" /> </route> 

I need something simple that can log test messages.

+5
source share
2 answers

Yes, see the eip magazine http://camel.apache.org/logeip.html

This allows you to log human readable messages to the journal. You might notice this, on the green tip on the log component page: http://camel.apache.org/log

+7
source

TL DR

from ("timer: // scheduler? fixedRate = true & period = 5s"). log ("Hello World!");

Let me introduce you to the simplest example written in Java DSL. I will use the Spring Boot Camel starter to configure the simplest executable code. This example will help you register a Hello World! to your console every 5 seconds in accordance with the quartz2 cron component of quartz2 .

Documentation to view:

Here is your simple Spring Boot demo application:

  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); } } 

Here is the easiest route that logs a HelloWorld! message HelloWorld! to the console every 5 seconds:

  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!"); } } 
0
source

All Articles