26.20. 在目的地上设置 JMS 提供程序选项
某些 JMS 提供程序,如 IBM 的 WebSphere MQ 需要对 JMS 目的地设置选项。例如,您可能需要指定 targetClient
选项。由于 targetClient
是 WebSphere MQ 选项,而不是 Camel URI 选项,您需要在 JMS 目标名称上设置该 URI,如下所示:
// ... .setHeader("CamelJmsDestinationName", constant("queue:///MY_QUEUE?targetClient=1")) .to("wmq:queue:MY_QUEUE?useMessageIDAsCorrelationID=true");
// ...
.setHeader("CamelJmsDestinationName", constant("queue:///MY_QUEUE?targetClient=1"))
.to("wmq:queue:MY_QUEUE?useMessageIDAsCorrelationID=true");
一些版本的 WMQ 在目标名称上不接受这个选项,您将获得如下例外:
com.ibm.msg.client.jms.DetailedJMSException: JMSCC0005: The specified value 'MY_QUEUE?targetClient=1' is not allowed for 'XMSC_DESTINATION_NAME'
com.ibm.msg.client.jms.DetailedJMSException: JMSCC0005: The specified
value 'MY_QUEUE?targetClient=1' is not allowed for
'XMSC_DESTINATION_NAME'
临时解决方案是使用自定义 DestinationResolver: