Unstructured Data

The payload can be set by direct assignment to the body property the message. Alternatively, the payload can be set indirectly by using the methods of the JadeGenericMessage class listed in the following table.

Method Description
appendBinary Adds the specified binary information to the end of the message body
appendString Adds the specified text to the end of the message body
appendStringAsUtf8 Encodes the specified text as UTF8 and adds to the end of the message body
appendStringUtf8 Adds the specified UTF8 text to the end of the message body

Before content is added, the message object must be initialized for sending. Do this by calling the createMessage method of the JadeGenericQueue class with the forPUT parameter set to true, or by calling the initializeForPut method of the JadeGenericMessage class on an existing message object.

The following code fragment shows a message being constructed from a text string.

// initialize the message
message := queue.createMessage(true);
// describe the type of data in the payload
message.format := "text/UTF8";
// build message payload
message.appendStringAsUtf8("Hello World");
message.appendStringAsUtf8("Glad to be here");
// insert message in queue
queue.putMessage(message, "");

When the message is retrieved, the format property can be examined to determine the type of data in the payload. The body property, which is of type Binary, can then be cast to the correct type. In this case, it would be more efficient to use the getUtf8bodyAsString method of the JadeGenericMessage class.

if message.format = "text/UTF8" then
    // str := message.body.String;
    str := message.getUtf8bodyAsString;
endif;