How to use JMS Properties on IBM MQ JMS Interface?

后端 未结 2 669
生来不讨喜
生来不讨喜 2021-01-18 15:43

I\'m using MQ JMS interface with MQ 6.0.2.

It seems that only pre defined properties are suported and not arbitrary ones. for instance, I can properly getJMSCo

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 16:24

    Per the JMS 1.1 specification:

    An identifier is an unlimited-length character sequence that must begin with a Java identifier start character; all following characters must be Java identifier part characters. An identifier start character is any character for which the method Character.isJavaIdentifierStart returns true. This includes ‘_’ and ‘$’. An identifier part character is any character for which the method Character.isJavaIdentifierPart returns true.

    Following the clues here takes us to the Javadoc for the Character.isJavaIdentifierPart method which lists the valid characters for an identifier:

    A character may be part of a Java identifier if any of the following are true:

    * it is a letter
    * it is a currency symbol (such as '$')
    * it is a connecting punctuation character (such as '_')
    * it is a digit
    * it is a numeric letter (such as a Roman numeral character)
    * it is a combining mark
    * it is a non-spacing mark
    * isIdentifierIgnorable(codePoint) returns true for the character
    

    Note that white space is specifically excluded from the set of valid identifier characters. The set of valid first characters is a little more restrictive and includes the following characters:

    * isLetter(ch) returns true
    * getType(ch) returns LETTER_NUMBER
    * ch is a currency symbol (such as "$")
    * ch is a connecting punctuation character (such as "_").
    

    Use a valid identifier and try again. For example:

    message.setStringProperty("my.arbitrary.name", "value");
    message.getStringProperty("my.arbitrary.name");

    Or possibly...

    message.setStringProperty("myArbitraryName", "value");
    message.getStringProperty("myArbitraryName");

    By the way, switch to V7 at your earliest opportunity. Not only is the support for properties much better in general, but the ability to directly read/write MQMD headers is vastly improved as shown in the IBM example.

提交回复
热议问题