2

I have a client in NodeJS using the MQTT module (mqtt.js) to communicate with a topic of WebSphere MQ, redirected to a queue : I need the result to be on a queue so I use a topic between the source and the destination (since MQTT protocol communicate only with topics).

So we have : NodeJS (source) -> Topic of Websphere MQ (intermediate) -> Queue of Websphere MQ (destination)

The problem is that the received messages on the queue of WebsphereMQ are MQHRF2 format but I need MQSTR.

I did not find any property in mqtt.js side to specify the format.

I supposed we can force it with IBM Websphere MQ, but how ? Can I create a channel or anything for this use, that's to say convert the receiving format ?

Thanks in advance for your help !

Configuration :

Constrains :

  • WebSphere MQ must be v7.5 (so I can't upgrade to v8 to use mqlight)
  • Better stay with the module MQTT.js

It works correctly when I publish directly on a topic via the WebSphere MQ explorer. However, it fails when I publish from the NodeJS application.

I tried both methods listing in the comments but I found a weird thing : The result is different according to if I use MQExplorer (what I always used) or the MQ console :

On the MQ Explorer : MQ Explorer

On the MQ Console, with the command : amqsbcg QUEUE_MQTT_VERIF MQTTVerification : MQ Console, with the command : amqsbcg  QUEUE_MQTT_VERIF MQTTVerification

As you can see, in the console, the format field is empty, whereas on the MQExplorer it is MQHRF2. The messages are also different.

So the result on the MQConsole is right whereas the MQExplorer still shows a wrong result after the changes. Note that the result is right only if changes has been done on both :

  • Subscription : ALTER SUB(APPLE.PRICES) PSPROP(NONE)
  • Queue : ALTER QLOCAL(PRICES) PROPCTL(NONE)

Maybe the source of the problem is just the display on MQExplorer software ?

EDIT:

The difference between MQExplorer and MQConsole was due to the parameter in MQ Explorer : Window -> Preferences -> WebSphereMQ Explorer -> Message properties -> Uncheck "Display message properties".

dng
  • 411
  • 1
  • 5
  • 18

1 Answers1

2

When redirecting publications made on a topic to a queue you probably have some definitions like this:-

DEFINE QLOCAL(PRICES)
DEFINE TOPIC(APPLES) TOPICSTR('Price/Fruit/Apples')
DEFINE SUB(APPLE.PRICES) TOPICOBJ(APPLES) DESTCLAS(PROVIDED) DEST(PRICES)

which redirects publications made on the topic string 'Price/Fruit/Apples' to the queue PRICES.

What you will find with such a set up however, is that the topic string is added to the message by the queue manager and thus adds an MQRFH2 header onto the front of your published message.

Message Descriptor (MQMD)
Report       :00000000
Message Type :8 (Datagram)
Format       :'MQHRF2  '
Priority     :0
Persistence  :0 (Not Persistent)
Message Id   :414D51204D51473120202020202020202D77835720003702
              'AMQ MQG1        -w.W .7.'
ReplyToQ     :'                                                '
ReplyToQMgr  :'MQG1                                            '
[  102 bytes] Message Content
<mqps>
  <Top>
    Price/Fruit/Apples
  </Top>
</mqps>
Apples are $2/kilo

To remove this without changing the application reading from the queue, make this alteration to the subscription.

ALTER SUB(APPLE.PRICES) PSPROP(NONE)

This stops the queue manager even putting the topic string into the message in the first place.

From your MQ Explorer screenshot, it can be seen that the MQRFH2 is still present after the SUB is changed to PSPROP(NONE) because there is another property present - mqtt.clientid. Since there are other items in the MQRFH2 as well as the topic string, then the SUB change will not remove those - only the topic string added by the queue manager. In that case, you should try the following.

If alternatively you want to have the topic string there sometimes and only remove it for applications that don't want to see it, you can make a similar change to the queue, which can be over-ridden in application code to force the properties to be delivered to the application, but otherwise they won't be. This would also allow you to read any existing messages that had already been published (the change to the SUB isn't retrospectively applied to messages that are already on the queue).

ALTER QLOCAL(PRICES) PROPCTL(NONE)

This will mean that applications that don't specifically request MQGMO_FORCE_RFH2 will see the message without the MQRFH2. The amqsbcg sample is one such application.

If an application codes MQGMO_FORCE_RFH2 it will still be able to see the properties in an MQRFH2 header because it has explicitly asked for that. You cannot stop that by changing the queue.

Your problem is only now with the way MQ Explorer chooses to display the message. There is a parameter in MQ Explorer : Window -> Preferences -> WebSphereMQ Explorer -> Message properties -> Uncheck "Display message properties" which will stop it forcing them to be an MQRFH2, and then you'll be all good.

Morag Hughson
  • 7,255
  • 15
  • 44
  • I did exactly what you said step by step but it still does't work... Maybe should we check anything else ? Alternatively, is there a possible way to remove the header, in order to keep only the received string content ? – dng Jul 13 '16 at 09:17
  • What happens when the the publication comes from an external source (here nodeJS) ? (cf : Edit post) – dng Jul 13 '16 at 09:53
  • which method did you use? Did you change the SUB or the QUEUE? If you changed the SUB, did you publish a new message to test if it worked? – Morag Hughson Jul 13 '16 at 21:38
  • Can you supply a view of your MQRFH2 header? Perhaps it isn't the topic string that is putting the MQRFH2 header on for you. Maybe you have something se annotating the message. – Morag Hughson Jul 13 '16 at 21:39
  • I updated my answer based on the assumption that publishing from NodeJS is putting other items, not related to the pub/sub engine, into your message and thus causing the MQRFH2 header to be added. If this is the case - making the suggested change on the queue is the way to go. – Morag Hughson Jul 16 '16 at 02:50
  • I tried both methods, the test works only if I use the MQ Explorer to publish, but not with the NodeApp. I updated my answer, please check it – dng Jul 18 '16 at 09:21
  • I updated my answer again based on your updates. In short, MQ Explorer is asking for the properties, amqsbcg is not, so you're all good so long as your own app doesn't ask for the properties explicitly. – Morag Hughson Jul 18 '16 at 23:29
  • Concerning the difference between MQExplorer and MQConsole, it was due to the parameter in MQ Explorer : Window -> Preferences -> WebSphereMQ Explorer -> Message properties -> Uncheck "Display message properties". Now it works like a charm thanks to your answer, thank you very much ! – dng Jul 20 '16 at 10:10
  • I updated my answer to include the MQ Explorer setting that you found. If you think we've got everything covered, perhaps you can accept the answer? – Morag Hughson Jul 20 '16 at 10:47