Question

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!

Was it helpful?

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.

OTHER TIPS

I'd suggest having a look at one of the samples in the WMQ installation - called SimpleWMQMDWrite.java

This does use setObjectProperty as follows:

  // Generate a custom message id
  byte[] customMessageId = new byte[24];
  for (int i = 0; i < 24; i++) {
    // Hex-string 010203040506070801020304050607080102030405060708
    customMessageId[i] = (byte) ((i % 8) + 1);
  }

  // Write to MQMD.MsgId via JMS_IBM_MQMD_MSGID message property
  message.setObjectProperty(WMQConstants.JMS_IBM_MQMD_MSGID, customMessageId);

The error message you've included though doesn't look much like a WMQ JMS error message more WebLogic, wonder if that has wrapped the message object and is doing some additional checking?

M.

Also you can transform your hex string to byte array using com.ibm.msg.client.commonservices.Utils.hexToBytes(yourHexString)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top