2012-04-12 2 views
1

필자의 요구 사항은 간단합니다. 단일 디렉토리를 폴링하고 필 요한 입력 파일의 파일 이름을 기반으로해야합니다.낙타 루트 - 파일 이름 필터 및 헤더 값 설정

가) 나를 위해 분명 헤더 값 B) ..

내가 followng가 작동해야하는 문서에이 acheive하는 몇 가지 방법을 시도했지만를 기반으로 한 특정 JMS 큐에 메시지를 다이렉트 설정 그것은

 <from uri="file:[some input directory]"/> 

     <when> 
      <simple>${file:name} contains 'new'</simple> 
      <setHeader headerName="messageType"> 
       <constant>NEW</constant> 
      </setHeader> 
      <to uri="jmsbroker:queue:[queue for new items]"/> 
     </when> 
     <when> 
      <simple>${file:name} contains 'amend'</simple> 
      <setHeader headerName="messageType"> 
       <constant>AMEND</constant> 
      </setHeader> 
      <to uri="jmsbroker:queue:[queue for amended items]"/> 
     </when> 
     <when> 
      <simple>${file:name} contains 'other'</simple> 
      <setHeader headerName="messageType"> 
       <constant>OTHER</constant> 
      </setHeader> 
      <to uri="jmsbroker:queue:[queue for other]"/> 
     </when> 
     <otherwise> 
      <bean ref="deadLetterErrorHandler"/> 
     </otherwise> 

    </route> 

어떤 도움

이 많이 감사 ...하지 않습니다. 당신이 <choice> <when> 주위 조건문을 누락

답변

2

안부, 앤디는 ... 오류 대기열로 <otherwise> 섹션해야 방금 경로도

합니다 (content based router docs 참조)하거나 예외를 던질

시도해주세요.

<route> 
     <from uri="file:/tmp/inbox"/> 
     <choice> 
      <when> 
       <simple>${file:name} contains 'new'</simple> 
       <setHeader headerName="messageType"> 
        <constant>NEW</constant> 
       </setHeader> 
       <to uri="jmsbroker:queue:newItems"/> 
      </when> 
      <otherwise> 
       <to uri="jmsbroker:queue:errorQueue"/> 
      </otherwise> 
     </choice> 
    </route>