javajmsarraysobject-properties

Cannot set the property value for JMS_IBM_MQMD_MsgId in weblogic, JMS, java


I want to send a message to a JMS Queue, and I want to set an object property:

tMessage.setObjectProperty("JMS_IBM_MQMD_MsgId", bytes); //bytes is a byte array value

But I am getting an exception for this row:

tMessage.setObjectProperty("JMS_IBM_MQMD_MsgId", toByteArray((phone+"IBM").toCharArray()));

Why cannot I set byte array to this property? I saw some example, and everyone sets bytearray, but I am getting exception:

weblogic.jms.common.MessageFormatException: [JMSClientExceptions:055123]Invalid property value, [B@48647dd0

Why? Thank you!


Solution

  • For setObjectProperty:

    The setObjectProperty method accepts values of class Boolean, Byte, Short, Integer, Long, Float, Double, and String. An attempt to use any other class must throw a JMSException.

    So it does not accept ByteArray. setObjectProperty accepts Object so you don't get compile error.