How to use JMS Properties on IBM MQ JMS Interface?

后端 未结 2 670
生来不讨喜
生来不讨喜 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:44

    If you have the complete client install, you can go to C:\Program Files\IBM\WebSphere MQ\tools\jms\samples\interactive\ or somewhere in /opt/mqm/samp and look for SampleConsumerJava.java and SampleProducerJava.java.

    From the sample Producer program:

      // Set custom properties
      msg.setStringProperty("MyStringProperty", "My Year Of Birth");
      msg.setIntProperty("MyIntProperty", 2007);
    

    And from the sample Consumer:

      // Get values for custom properties, if available
      String property1 = msg.getStringProperty("MyStringProperty");
    
      // Get value for an int property, store the result in long to validate
      // the get operation.
      long property2 = ((long) Integer.MAX_VALUE) + 1;
      property2 = msg.getIntProperty("MyIntProperty");
    
      if ((property1 != null) && (property2 < Integer.MAX_VALUE)) {
        System.out.println("[Message has my custom properties]");
    

    Property names follow the rules for Java variable names and cant have spaces in them.

提交回复
热议问题