헤더의 값을 설정하여 어떤 서비스인지를 표시 한 다음이를 낙타 경로에서 전송합니다. 이 접근법은 이것을하는 한 가지 방법 일뿐입니다. Christian Schneider는 제가 지금까지 훨씬 더 많이 사용하게 될 훌륭한 솔루션을 가지고 있습니다. 그러나 둘 다 똑같은 것을 성취 할 것이며 당신이 묻는 사람에 따라 다른 사람보다 더 분명 할 수도 있습니다.
예를 들어, 당신은 할 수 있습니다 : 당신은 다음 자바 DSL 또는 스프링 DSL 하나의 헤더 필터링 할 수 있습니다
public void foo(Exchange exchange){
exchange.getIn().setHeader("MsgType", "Student");
}
. 당신이 봄 DSL에서이 같은 (의사 코드)
from("foo:incommingroute")
.choice()
.when(header("MsgType").equals("Student"))
.to("webservice:Student")
.when(header("MsgType").equals("Employee"))
.to("webservice:Employee")
.otherwise()
.to("jms:Deadletter")
.end();
할 것 자바 DSL에서
당신은 당신은 또한 볼 수있는이 (의사 코드) 같은
<route>
<from uri="foo:incommingroute"/>
<choice>
<when>
<simple>${header.MsgType} equals 'Student'</simple>
<to uri="webservice:Student"/>
</when>
<when>
<simple>${header.MsgType} equals 'Employee'</simple>
<to uri="webservice:Employee"/>
</when>
<otherwise>
<to uri="jms:badOrders"/>
<stop/>
</otherwise>
</choice>
<to uri="jms:Deadletter"/>
</route>
할 것 이 링크 http://camel.apache.org/content-enricher.html에서 더 풍부한 패턴. 기본적으로 제가 제안하는 것은 더 풍성한 패턴을 따르는 것입니다. 당신이 나에게 어떻게 카멜에게 메시지를 보내고 있는지 말할 수 있다면 아마도 더 많은 것을 도울 수있을 것입니다.
호프 이것은 약간의 아이디어를주고 코드에 문법 오류가 있다면 유감스럽게 생각합니다. 버스 정류장에 있으며 점검 할 시간이 없었습니다. .
터미널에. 헤더에 헤더를 구별하는 방법을 식별하는 데 도움이되는 정보가있을 수 있습니다. – Namphibian