2

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!

victorio
  • 6,224
  • 24
  • 77
  • 113
  • Can you post the exception? – user987339 Nov 07 '13 at 12:19
  • @victorio can you post some sample code to set message I am facing issue with setting message id here is the link for my question https://stackoverflow.com/questions/52889361/how-to-set-message-id-for-ibm-mq-using-java-program/52890449?noredirect=1#comment92764464_52890449 – kushma gonna Oct 29 '18 at 11:12

3 Answers3

2

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.

user987339
  • 10,519
  • 8
  • 40
  • 45
1

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.

Calanais
  • 1,541
  • 9
  • 10
0

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