Guest User

Untitled

a guest
May 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package com.example.demo;
  2.  
  3. import org.apache.camel.CamelContext;
  4. import org.apache.camel.builder.RouteBuilder;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.boot.ApplicationArguments;
  7. import org.springframework.boot.ApplicationRunner;
  8. import org.springframework.boot.SpringApplication;
  9. import org.springframework.boot.autoconfigure.SpringBootApplication;
  10.  
  11. @SpringBootApplication
  12. public class SpringCamelStartApplication extends RouteBuilder implements ApplicationRunner {
  13.  
  14. public static void main(String[] args) {
  15. SpringApplication.run(SpringCamelStartApplication.class, args);
  16. }
  17.  
  18. @Autowired
  19. private CamelContext camelContext;
  20.  
  21. @Override
  22. public void run(ApplicationArguments arg0) throws Exception {
  23.  
  24. camelContext.getShutdownStrategy().setTimeout(20L);
  25. camelContext.start();
  26. Thread.currentThread().join();
  27. }
  28.  
  29. @Override
  30. public void configure() throws Exception {
  31. from("timer://foo?fixedRate=true&period=1000")
  32. .setBody(simple("SELECT * FROM user_test ORDER BY user_id DESC LIMIT 1;"))
  33. .log("JDBC Query : ${body}")
  34. .to("jdbc:dataSource?useHeadersAsParameters=true")
  35. .log("JDBC Result : ${body}");
  36. }
  37. }
Add Comment
Please, Sign In to add comment