0

We develop an .NET application which connects to IBM MQ with IBM XMS library. It's working, but the produced messages contains the MQRFH2 header, which the target application cannot process, so we have to remove it. This normally can be done by set a property like https://www.ibm.com/docs/en/ibm-mq/9.1?topic=definitions-xmsc-wmq-target-client. We tried this by setting cf.SetIntProperty(IBM.XMS.XMSC.WMQ_TARGET_CLIENT, IBM.XMS.XMSC.WMQ_TARGET_DEST_MQ);

                IBM.XMS.IConnection connectionWMQ;
                IBM.XMS.XMSFactoryFactory factoryFactory;
                IBM.XMS.IConnectionFactory cf;

                factoryFactory = IBM.XMS.XMSFactoryFactory.GetInstance(IBM.XMS.XMSC.CT_WMQ);
                cf = factoryFactory.CreateConnectionFactory();

                cf.SetStringProperty(IBM.XMS.XMSC.WMQ_HOST_NAME, mqQueueOptions.HostName);
                cf.SetIntProperty(IBM.XMS.XMSC.WMQ_PORT, mqQueueOptions.Port);
                cf.SetStringProperty(IBM.XMS.XMSC.WMQ_CHANNEL, mqQueueOptions.Channel);
                cf.SetIntProperty(IBM.XMS.XMSC.WMQ_CONNECTION_MODE, IBM.XMS.XMSC.WMQ_CM_CLIENT);
                cf.SetStringProperty(IBM.XMS.XMSC.WMQ_QUEUE_MANAGER, mqQueueOptions.QueueManager);
                cf.SetIntProperty(IBM.XMS.XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, IBM.XMS.XMSC.WMQ_CLIENT_RECONNECT);
                cf.SetIntProperty(IBM.XMS.XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, IBM.XMS.XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
                cf.SetIntProperty(IBM.XMS.XMSC.WMQ_TARGET_CLIENT, IBM.XMS.XMSC.WMQ_TARGET_DEST_MQ);

But then we get:

Retry 00:00:02 of RetryPolicy-1d242dc3 at , due to: 'IBM.XMS.XMSException: Value 1 not valid for property: targetClient
   at IBM.XMS.Client.Impl.XmsPropertyContextImpl.SetObjectPropertyInternal(String name, Object value, Boolean validationEnabled)
   at IBM.XMS.Client.Impl.XmsPropertyContextImpl.SetObjectProperty(String name, Object value)
   at IBM.XMS.Client.Impl.XmsPropertyContextImpl.SetIntProperty(String name, Int32 value)

What's the problem?

Tried by setting cf.SetIntProperty(IBM.XMS.XMSC.WMQ_TARGET_CLIENT, IBM.XMS.XMSC.WMQ_TARGET_DEST_MQ); to remove the RF2H header but get exception of invalid value for the property.

Daniel M.
  • 15
  • 3
  • How do you open your queue? – JoshMc May 09 '23 at 15:52
  • Does this answer your question? [Is there an MQ/XMS equivalent for the MQ/JMS setTargetClient](https://stackoverflow.com/questions/58767479/is-there-an-mq-xms-equivalent-for-the-mq-jms-settargetclient) – JoshMc May 10 '23 at 12:04

2 Answers2

2

In a roundabout way this question is a duplicate of Is there an MQ/XMS equivalent for the MQ/JMS setTargetClient

In Summary

You are setting the property on the connection factory. It needs to set it on the destination. Same syntax as you have, but somewhere later in the code when you have instantiated a destination object.

destination.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_MQ);

See: https://www.ibm.com/docs/en/ibm-mq/9.3?topic=definitions-xmsc-wmq-target-client

chughts
  • 4,210
  • 2
  • 14
  • 27
0

In my opinion, based on what JMS does, that should have worked.

My next thought would be to set it on the Destination object and not for the connection object.

FYI:

targetClient=0 means it is sending a JMS message
targetClient=1 means it is sending an MQ message (non-JMS)

So, did you try setting the property as a boolean?

i.e.

cf.SetBooleanProperty(IBM.XMS.XMSC.WMQ_TARGET_CLIENT, true);
Roger
  • 7,062
  • 13
  • 20