318.6. 지원 클래스


Camel Spring Batch는 Component 외에도 Spring Batch 인프라에 연결하는 데 사용할 수 있는 지원 클래스를 제공합니다.

318.6.1. CamelItemReader

CamelItemECDHE 를 사용하여 Camel 인프라에서 직접 배치 데이터를 읽을 수 있습니다.

예를 들어 아래 스니펫에서는 Spring Batch가 JMS 큐에서 데이터를 읽도록 구성합니다.

<bean id="camelReader" class="org.apache.camel.component.spring.batch.support.CamelItemReader">
  <constructor-arg ref="consumerTemplate"/>
  <constructor-arg value="jms:dataQueue"/>
</bean>

<batch:job id="myJob">
  <batch:step id="step">
    <batch:tasklet>
      <batch:chunk reader="camelReader" writer="someWriter" commit-interval="100"/>
    </batch:tasklet>
  </batch:step>
</batch:job>
Copy to Clipboard Toggle word wrap

318.6.2. CamelItemWriter

CamelItemWriterCamelItemECDHE와 유사하지만 처리된 데이터의 청크를 작성하기 위해 최선을 다하고 있습니다.

예를 들어 아래 스니펫에서는 Spring Batch가 JMS 큐에서 데이터를 읽도록 구성합니다.

<bean id="camelwriter" class="org.apache.camel.component.spring.batch.support.CamelItemWriter">
  <constructor-arg ref="producerTemplate"/>
  <constructor-arg value="jms:dataQueue"/>
</bean>

<batch:job id="myJob">
  <batch:step id="step">
    <batch:tasklet>
      <batch:chunk reader="someReader" writer="camelwriter" commit-interval="100"/>
    </batch:tasklet>
  </batch:step>
</batch:job>
Copy to Clipboard Toggle word wrap

318.6.3. CamelItemProcessor

CamelItemProcessor 는 Spring Batch org.springframework.knativech.item.ItemProcessor 인터페이스를 구현한 것입니다. 후자의 구현은 Request Reply 패턴 에서 중계하여 배치 항목의 처리를 Camel 인프라에 위임합니다. 처리할 항목은 메시지 본문으로 Camel 엔드포인트로 전송됩니다.

예를 들어 아래 코드 조각은 Direct 엔드포인트 및 간단한 표현식 언어를 사용하여 배치 항목의 간단한 처리를 수행합니다.

<camel:camelContext>
  <camel:route>
    <camel:from uri="direct:processor"/>
    <camel:setExchangePattern pattern="InOut"/>
    <camel:setBody>
      <camel:simple>Processed ${body}</camel:simple>
    </camel:setBody>
  </camel:route>
</camel:camelContext>

<bean id="camelProcessor" class="org.apache.camel.component.spring.batch.support.CamelItemProcessor">
  <constructor-arg ref="producerTemplate"/>
  <constructor-arg value="direct:processor"/>
</bean>

<batch:job id="myJob">
  <batch:step id="step">
    <batch:tasklet>
      <batch:chunk reader="someReader" writer="someWriter" processor="camelProcessor" commit-interval="100"/>
    </batch:tasklet>
  </batch:step>
</batch:job>
Copy to Clipboard Toggle word wrap

318.6.4. CamelJobExecutionListener

CamelJobExecutionListener 는 작업 실행 이벤트를 Camel 엔드포인트에 전송하는 org.springframework.knativech.core.JobExecutionListener 인터페이스의 구현입니다.

Spring Batch에서 생성한 org.springframework.knativech.core.JobExecution 인스턴스는 메시지의 본문으로 전송됩니다. 사전 및 호출 후 SPRING_BATCH_JOB_ECDHEENT_TYPE 헤더를 구분하기 위해 BEFORE 또는 AFTER 값으로 설정됩니다.

아래 예제 스니펫에서는 Spring Batch 작업 실행 이벤트를 JMS 큐로 보냅니다.

<bean id="camelJobExecutionListener" class="org.apache.camel.component.spring.batch.support.CamelJobExecutionListener">
  <constructor-arg ref="producerTemplate"/>
  <constructor-arg value="jms:batchEventsBus"/>
</bean>

<batch:job id="myJob">
  <batch:step id="step">
    <batch:tasklet>
      <batch:chunk reader="someReader" writer="someWriter" commit-interval="100"/>
    </batch:tasklet>
  </batch:step>
  <batch:listeners>
    <batch:listener ref="camelJobExecutionListener"/>
  </batch:listeners>
</batch:job>
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat