我是Apache Camel的新手。我已經將我的應用程序設置爲使用基於XML配置的Apache Camel。我的配置包含多個具有相似步驟的路線。我試圖找到一種方法來將這些不同路線的共同或重複部分放置在一個地方,並將它們從路線中引用而不是一次又一次地重複它們?如何寫簡潔的apache駱駝xml
例如,在我下面的駱駝路線配置中,路線2重複了路線1的幾個步驟。那麼是否有辦法提取路線1和路線2的常見步驟,然後參考路線1和2中提取的部分?
<context:property-placeholder location="classpath:quartz.properties" />
<context:component-scan base-package="com"></context:component-scan>
<camel:route>
<camel:from uri="quartz://deadlines/SDGWD?cron=15+34+14+?+*+MON-SUN+*" />
<camel:onCompletion>
<camel:to uri="seda:checkAnyPendingDeadlines"/>
</camel:onCompletion>
<camel:to uri="bean:sdgwdNotifier" />
<camel:choice>
<camel:when>
<camel:method ref="deadlineHandler" method="canProcessDeadline" />
<camel:bean ref="deadlineHandler" method="prepareDeadline" />
<camel:bean ref="sdgwdProcessor" method="initiateMessageProcessing" />
<camel:bean ref="schedulerXdrTransformer" method="marshall" />
<camel:to uri="wmq:SU.SES" />
<camel:bean ref="sdgwdProcessor" method="waitForAcknowledgment" />
<camel:bean ref="sdgwdProcessor" method="afterMessageProcessed" />
<camel:bean ref="deadlineHandler" method="onDeadlineProcessingCompletion" />
</camel:when>
<camel:otherwise>
<camel:bean ref="deadlineHandler" method="enqueDeadline" />
</camel:otherwise>
</camel:choice>
</camel:route>
<camel:route>
<camel:from uri ="seda:checkAnyPendingDeadlines"/>
<camel:onCompletion>
<camel:to uri ="seda:checkAnyPendingDeadlines"/>
</camel:onCompletion>
<camel:to uri="bean:deadlineHandler?method=getNextProcessableDeadline" />
<camel:choice>
<camel:when>
<camel:method ref="deadlineHandler" method="canProcessDeadline" />
<camel:bean ref="deadlineHandler" method="prepareDeadline" />
<camel:choice>
<camel:when>
<camel:simple>${body.deadline} == ${type:settlementcontrol.scheduler.model.Deadline.SDGW} </camel:simple>
<camel:bean ref="sdgwdProcessor" method="initiateMessageProcessing" />
<camel:bean ref="schedulerXdrTransformer" method="marshall" />
<camel:to uri="wmq:SU.SES" />
<camel:bean ref="sdgwdProcessor" method="waitForAcknowledgment" />
<camel:bean ref="sdgwdProcessor" method="afterMessageProcessed" />
<camel:bean ref="deadlineHandler" method="onDeadlineProcessingCompletion" />
</camel:when>
</camel:choice>
</camel:when>
<camel:otherwise>
<camel:bean ref="deadlineHandler" method="enqueDeadline" />
</camel:otherwise>
</camel:choice>
</camel:route>
感謝, Vaibhav的
謝謝@羅伯特。我已經使用直接組件提取出了通用部分。但是,我仍然希望避免重複的子路線上還有很少的步驟。 Apache駱駝文檔稱AOP已被棄用。那麼有沒有更好的方法來圍繞建議實現AOP? – Vaibhav
你能解釋爲什麼這些步驟不能成爲普通流程的一部分(或舉例),讓我更好地把握這個問題? –