XML DSL은 코드 변경 없이 라우팅 규칙을 수정할 수 있다는 장점이 있습니다. 특히 Spring XML 설정 방식에 익숙한 팀이나, 운영 중 동적 변경이 필요한 경우에 유용합니다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring">
<camelContext id="camelContext"
xmlns="http://camel.apache.org/schema/spring">
<route id="order-route">
<from uri="file:orders/inbox?noop=true"/>
<log message="파일 수신: ${header.CamelFileName}"/>
<choice>
<when>
<simple>${header.CamelFileName} contains 'urgent'</simple>
<to uri="direct:urgentOrder"/>
</when>
<otherwise>
<to uri="direct:normalOrder"/>
</otherwise>
</choice>
</route>
</camelContext>
</beans> Spring Boot 환경에서는 application.yml로 Camel 기본 설정을 관리합니다.
camel:
springboot:
name: MyApp
main-run-controller: true
dataformat:
json-jackson:
auto-discover-object-mapper: true
# Camel 라우트 자동 검색 패턴
routes-include-pattern: "classpath:camel/*.xml" XML DSL에서 Spring Bean을 참조하는 방법입니다.
<!-- Spring Bean 정의 -->
<bean id="orderService" class="com.example.OrderService"/>
<!-- Camel 라우트에서 Bean 참조 -->
<route>
<from uri="direct:processOrder"/>
<bean ref="orderService" method="process"/>
<to uri="jms:queue:completed"/>
</route> 환경별 설정값을 외부화하는 것은 Camel에서도 중요합니다.
# application.properties
order.input.dir=orders/inbox
jms.queue.name=orderQueue
retry.count=3 <!-- XML DSL에서 프로퍼티 사용 -->
<route>
<from uri="file:{{order.input.dir}}?noop=true"/>
<to uri="jms:queue:{{jms.queue.name}}"/>
</route> // Java DSL에서 프로퍼티 사용
from("file:{{order.input.dir}}?noop=true")
.to("jms:queue:{{jms.queue.name}}"); Camel 3.x 이후 YAML DSL도 지원합니다. Camel K (클라우드 네이티브 통합)에서 주로 사용됩니다.
- route:
id: order-route
from:
uri: "file:orders/inbox"
parameters:
noop: true
steps:
- log:
message: "파일 수신: ${header.CamelFileName}"
- to: "jms:queue:orders" 코스피 8% 폭락, 서킷브레이커 발동, SK텔레콤 Claude AI 차단까지. 한국의 AI 레버리지 버블이 단 하루…
SNS 사진 1장으로 30초 만에 딥페이크 영상이 완성됩니다. 당신의 얼굴이 이미 범죄에 악용되고 있을 수…
SNS 사진 1장으로 30초 만에 딥페이크 영상이 완성됩니다. 당신의 얼굴이 이미 범죄에 악용되고 있을 수…
달러/원 환율이 급등하는 이유와 실생활 영향을 정리했습니다. 지금 당장 활용할 수 있는 환전·투자 대응 전략까지…
미래에셋·미래에셋벤처투자·미래에셋생명이 동반 급등한 이유는 스페이스X 상장 기대감입니다. 세 회사가 스페이스X와 어떻게 연결되어 있는지 상세히 분석했습니다.
스페이스X 상장이 계속 미뤄지는 진짜 이유를 파헤쳤습니다. 화성 계획, 스타링크 분리, 국방 계약... 머스크가 절대…