58.21. 在目的地上设置 JMS 提供程序选项
某些 JMS 提供程序,如 IBM 的 WebSphere MQ 需要在 JMS 目的地上设置选项。例如,您可能需要指定 targetClient 选项。由于 targetClient 是 WebSphere MQ 选项,而不是 Camel URI 选项,您需要在 JMS 目标名称上设置,如下所示:
// ...
.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: