Topic
3 replies Latest Post - ‏2013-05-10T03:38:26Z by GBaddeley
LI.YG
LI.YG
14 Posts
ACCEPTED ANSWER

Pinned topic PutAppName

‏2013-05-03T03:40:25Z |

Hi,

 

I am trying to put a message with MQ7 in windows xp. C++ is used. The message is totally fine, but the header gives me a trouble:

<Property name="JMSXAppID" type="STRING">d:\WMQ.exeNUL...NUL</Property>

There are 18 NUL chars, which makes the total length of the put app name to be 28. The xml element is generated from a vendor program by reading the queue. When parsing the xml file, the program will crash. If the NUL chars are removed manually, then the parsing process is ok.

I tried to set the PutAppName before sending the message to the queue, but it does not work. Before calling "put", PutAppName contains 28 null chars. I then tried setPutApplicationType and setPutApplicationName, but none of them works. Other attributes, like ReplyToQMgr and UserIdentifier can be set properly.

What is wrong with my approach? Is there any other way to solve the problem? Let me know if any point is unclear. Thanks.

Regards,

--YG

  • Morag Hughson
    Morag Hughson
    140 Posts
    ACCEPTED ANSWER

    Re: PutAppName

    ‏2013-05-03T18:52:05Z  in response to LI.YG

    What is wrong with my approach?

    In order to set context fields, of which PutApplName is one, you must have opened the queue with the MQOO_SET_ALL_CONTEXT option, and issued the put to the queue with the MQPMO_SET_ALL_CONTEXT option. If you don't do this the queue manager will overlay anything in those fields with the information it gets back from the O/S identifying your application. To successfully use the MQOO_SET_ALL_CONTEXT option you must also have a level of authority to allow you to set your own context information (as you could be using this to masquerade as another application!).

    Is there any other way to solve the problem?

    I am surprised that the PutApplName is null-padded rather than being blank-padded. Read about that here. You could check this by running the amqsbcg sample against your queue and taking a look at the PutApplName that it displays.

    The xml element is generated from a vendor program by reading the queue.

    Is there a possibility that this program is replacing the blanks with nulls?

    • LI.YG
      LI.YG
      14 Posts
      ACCEPTED ANSWER

      Re: PutAppName

      ‏2013-05-07T07:21:50Z  in response to Morag Hughson

      Hi Morag,

       

      Thanks a lot for your detailed reply. I tried out SET_ALL_CONTEXT. It works now. My program is the only user for the put queue, so I assume it will not affect others.

       

      Regards,

      --YG

  • GBaddeley
    GBaddeley
    265 Posts
    ACCEPTED ANSWER

    Re: PutAppName

    ‏2013-05-10T03:38:26Z  in response to LI.YG

    >What is wrong with my approach? Is there any other way to solve the problem?

    It is a very rare requirement for an application to actually set any of the MQ context fields, such as application name. MQ should automatically populate these with acceptable values for you.

    Setting the context fields requires elevated authority to be granted, and allows the application (and any other app running with the same MQ credentials) to impersonate or falsely state the application name. This has implications for security and auditability. It opens up an attack vector where a rogue application could cause damage to the MQ infrastructure and not be traceable.

    HTH, G.