31.20. 在目的地上设置 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: