我的用例(骆驼):
如果传入的消息具有correlationId(比如clientCorrId)=>离开,则什么都不做,因为客户端使用clientCorrId来映射响应。
如果传入消息没有correlationId =>取messageId并将其放入correlationId(在路由级别,而不是在使用“jms”组件的每个路由中)
复制correlationId 应该只在路由级别完成
如何在路由级别进行 corrleationId 复制?(不是全局的,如下所示的 useMessageIDAsCorrelationID)
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<!--property name="useMessageIDAsCorrelationID" value="true" / WARNING! Do not use this as we need to copy only in the beginning not everywhere -->
<property name="transactionManager" ref="jpaTransactionManager" />
<property name="transacted" value="true" />
</bean>
我想避免使用像这样的单独 bean 代码来复制 correlationId ONLYIF 它是空的:
if (EMPTY_MSG_ID.equals(currentCorrId)) {
log.info("No corrId set, setting msgId to corrid :" + msgId);
outHeader.put(correlationIdKey, msgId);
} else {
outHeader.put(correlationIdKey, currentCorrId);
log.info("CorrId already set: " + currentCorrId);
}