2016-08-03 3 views
1

한 응용 프로그램에 Apache camel 및 spring boot를 사용하고 있습니다. 디렉토리에서 읽은 다음 XML을 비동기로 읽은 다음 비 정렬 화 된 객체를 처리하여 더 많은 데이터를 설정 한 다음 다시 마샬링하고 다른 폴더로 보내야합니다. 다음 경로를 사용하고 있습니다. 프로세서로 언 마샬링 (unmarshalling) 한 후 POJO를 보내는 방법을 알려주십시오. 현재는 기본적으로 교환기가 프로세서로 들어갑니다. 프로세서를 사용하는 경우비 정렬 객체를 Camel 프로세서에 전달하십시오.

@SpringBootApplication 
public class CamelApplication extends FatJarRouter { 

    public static void main(String ... args) { 
     SpringApplication.run(CamelApplication.class, args); 
    } 

    @Override 
    public void configure() throws Exception { 
     from("file:input?noop=true") 
     .log("Read from the input file") 
     .unmarshal(new XMLtoPOJO()) 
     .log("Unmarshalled the xml") 
     .process(new MyProcessortoSetMoreDatatoPOJO()) 
     .log("Enriched with more data in processor") 
     .to("file:destination") 
     .log("Written to output file"); 
    } 
} 

답변

1

다음과 같이 교환에서 POJO를 얻을 수 있습니다 :

MyPojo pojo = exchange.getIn().getBody(MyPojo.class); 

대신 프로세서의 당신은 단지 POJO의 방법 서명과 일반 POJO 빈을 쓸 수 있습니다 사용하는 콩

public void doSomething(MyPojo pojo) 

그런 다음 해당 콩을 Camel에서 호출하십시오. 자세한 내용보기 : http://camel.apache.org/bean

관련 문제