Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Route:
  2. public void configure() throws Exception {
  3. from("quartz://batch?trigger.repeatCount=0&trigger.repeatInterval=0").beanRef("fileAggregator","collectFiles");
  4. }
  5.  
  6. Receive: never breaks out
  7. public void collectFiles() {
  8. while (true) {
  9. Exchange exch = consumer.receive("file:///temp/src/data");
  10. if (exch==null) {
  11. break;
  12. }
  13. System.out.println(exch.getIn().getHeader(Exchange.FILE_NAME));
  14. }
  15. }
  16.  
  17. ReceiveNoWait: breaks out immediately
  18. public void collectFiles() {
  19. while (true) {
  20. Exchange exch = consumer.receiveNoWait("file:///temp/src/data");
  21. if (exch==null) {
  22. break;
  23. }
  24. System.out.println(exch.getIn().getHeader(Exchange.FILE_NAME));
  25. }
  26. }
  27.  
  28. Receive Wait 1000: breaks out immediately
  29. public void collectFiles() {
  30. while (true) {
  31. Exchange exch = consumer.receive("file:///temp/src/data",1000);
  32. if (exch==null) {
  33. break;
  34. }
  35. System.out.println(exch.getIn().getHeader(Exchange.FILE_NAME));
  36. }
  37. }
  38.  
  39. Receive Wait 2000: System.out prints
  40. public void collectFiles() {
  41. while (true) {
  42. Exchange exch = consumer.receive("file:///temp/src/data",1000);
  43. if (exch==null) {
  44. break;
  45. }
  46. System.out.println(exch.getIn().getHeader(Exchange.FILE_NAME));
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement