2014-05-20 1 views
0

제 요구 사항은 몇 분마다 데이터베이스를 폴링하고 SQL을 얻는 것입니다. 따라서 내 코드는요소 'simple'로 시작하는 잘못된 콘텐츠가 발견되었습니다. 낙타 문제

<camel:route> 

     <camel:from uri="timer:dataRetrieve?period=5s"/> 

      <camel:to uri="sql:select output_obj,create_dt,destination_type from dbo.gcas_events_test where process_sw = 'N' order by create_dt desc" /> 


     </camel:route> 

내 데이터 세트에서 3 개의 필드가 필요합니다. 나는 destination_type = 'SEC'인지보고 싶다. 그러면 다른 경로로 가야한다.

그래서 생각해 냈습니다.

<camel:route> 

       <camel:from uri="timer:dataRetrieve?period=5s"/> 

        <camel:to uri="sql:select output_obj,create_dt,destination_type from dbo.gcas_events_test where process_sw = 'N' order by create_dt desc" /> 
       <camel:choice> 
         <camel:when> 
          <simple>${body.destination_type}='SEC'</simple> 
          <camel:to uri="foo" /> 
         </camel:when> 

        </camel:choice> 

       </camel:route> 

간단한 태그에 오류가 발생합니다. ognl과 비슷한 문제. 여기서 내가 뭘 잘못하고 있니? ${body.destination_type}='SEC'도 사용할 수 있습니까? (데이터 집합에 해당 값이 있다고 가정).

답변

1

Camel doc에 따르면 select 문은 다르게 구성되지 않은 경우 List<Map<String, Object>>입니다.

<camel:route> 
    <camel:from uri="timer:dataRetrieve?period=5s"/> 
    <camel:to uri="sql:select output_obj,create_dt,destination_type from dbo.gcas_events_test where process_sw = 'N' order by create_dt desc" /> 
    <camel:choice> 
     <camel:when> 
      <camel:simple>${body[0][destination_type]} == 'SEC'</simple> 
      <camel:to uri="foo" /> 
     </camel:when> 
    </camel:choice> 
</camel:route> 

경우 :

${body[0][destination_type]} 

경로의 정의는 다음과 같다 (대신 간단한 === 사용)해야 다음과 같이 귀하의 경우에, 당신의 결과 세트에서 처음으로 발견 된 destination_type 액세스 할 수 있습니다 결과 집합의 모든 레코드를 하나씩 처리해야합니다. 그러면 splitter :

<camel:route> 
    <camel:from uri="timer:dataRetrieve?period=5s"/> 
    <camel:to uri="sql:select output_obj,create_dt,destination_type from dbo.gcas_events_test where process_sw = 'N' order by create_dt desc" /> 
    <camel:split> 
     <camel:simple>${body}</camel:simple> 
     <camel:choice> 
      <camel:when> 
       <camel:simple>${body[destination_type]} == 'SEC'</simple> 
       <camel:to uri="foo" /> 
      </camel:when> 
     </camel:choice> 
    </camel:split> 
</camel:route> 
+0

을 사용할 수 있습니다. 고마워. – Krishna

관련 문제