我的用例(骆驼):
如果传入的消息有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);
}