I’m trying to consume JMS messages send over WebSphere MQ (WebSphere MQ Server v7) by .NET application using .NET WMQ API. I’m using WebSphere MQ Client v7.5 and amqmdnet.dll version 7.5.0.0.
There is some very strange behavior when reading JMSDeliveryMode property (Dlv property from jms RFH2 folder). The property value send by JMS application (servlet hosted in WebSphere Application Server v7) is set to Persistent (2) but my .NET client always reads 1 (which means Non_persistent). I need to read the correct value because my .NET application works as router/forwarder and it must forward message with correct configuration.
I tried to simulate JMS messages using RFHUtils. When I set delivery mode to 1 and send it to my .NET client it again reads 1 but if I also change persistence of MQ message in MQMD it reads 0. It looks like the value in JMSDeliveryMode is not used at all and .NET client always reads value from Persistence property but it is incorrect behavior! These two properties have different ranges of correct values:
JMSDeliveryMode correct values (from jms.jar):
- 1 –
DeliveryMode.NON_PERSISTENT - 2 –
DeliveryMode.PERSISTENT
Persistence correct values (from amqmdnet.dll):
- 0 –
MQC.MQPER_NOT_PERSISTENT - 1 –
MQC.MQPER_PERSISTENT - 2 –
MQC.MQPER_PERSISTENCE_AS_Q_DEF/MQC.MQPER_PERSISTENCE_AS_TOPIC_DEF
It is again bug in IBM’s amqmdnet.dll. After disassembling the library with .NET Reflector and checking the code responsible for reading JMS properties (
GetJmsPropertyprivate method ofMQMessageclass) I found this:The problem is that
propertiescollection never contains any property withJMSDeliveryModeas a key.propertiescollection contains RFH2 headers in format RFH2Folder.RFH2PropertyName. The correct property name forJMSDeliveryModeisjms.Dlv! InterestinglyGetJmsHeadermethod reads all JMS properties and all other properties use correct RFH2 name when searching in properties collection!The situation was even worse when I checked the reverse operation – private method
SetJmsPropertyfromMQMessageclass. SettingJMSDeliveryModecontains this code:So setting
JMSDeliverymode will either fire exception or set invalid persistence! Here is small test for reproducing the problem: