יום חמישי, 30 במאי 2013

Camel setHeader

The following camel sample code demonstrates reading text from the console writing it to both to a file and to a console .

  1: try {
  2: 	CamelContext context = new DefaultCamelContext();	
  3: 	context.addRoutes(new RouteBuilder() {
  4: 	public void configure() {
  5: 
  6: 		from("stream:in?promptMessage=Enter something please :").
  7: 		setHeader(Exchange.FILE_NAME, constant("myTxt.txt"))
  8: 		.to("file:target/TestmyFiles").
  9: 			to("stream:out");
 10: 	}
 11: 	});
 12: 	context.start();
 13: 	//Let the camel thread route to work in its thread
 14: 	Thread.sleep(334000);
 15: 	 System.out.print("I'm out");
 16: 			 
 17: } catch (Exception e) {
 18: 	e.printStackTrace();
 19: }

The camel framework auto create the file if it is not exist and override the file content every new route execution  .

אין תגובות:

הוסף רשומת תגובה