169.20. 宛先での JMS プロバイダーオプションの設定
IBM の WebSphere MQ などの一部の JMS プロバイダーでは、JMS 宛先にオプションを設定する必要があります。たとえば、targetClient オプションを指定する必要がある場合があります。targetClient は Camel URI オプションではなく WebSphere MQ オプションであるため、JMS 宛先名に設定する必要があります。
// ...
.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'
回避策として、カスタムの DestinationResolver を使用できます。
JmsComponent wmq = new JmsComponent(connectionFactory);
wmq.setDestinationResolver(new DestinationResolver() {
public Destination resolveDestinationName(Session session, String destinationName, boolean pubSubDomain) throws JMSException {
MQQueueSession wmqSession = (MQQueueSession) session;
return wmqSession.createQueue("queue:///" + destinationName + "?targetClient=1");
}
});