MQeFields is a container data structure widely used in WebSphere MQ Everyplace. You can put various types of data into the container. It is particularly useful for representing data that needs to be transported, such as messages. The following code creates an MQeFields structure:
/* create an MQeFields object */ MQeFields fields = new MQeFields( );
MQeFieldsHndl hFields; rc = mqeFields_new(&exceptBlock, &hFields);
MQeFields contains a collection of orderless fields. Each field consists of a triplet of entry name, entry value, and entry value type. MQeFields forms the basis of all WebSphere MQ Everyplace messages.
Use the entity name to retrieve and update values. It is good practice to keep names short, because the names are included with the data when the MQeFields item is transmitted.
The following example shows how to store values in an MQeFields item:
/* Store integer values into a fields object */ fields.putInt( "Int1", 1234 ); fields.putInt( "Int2", 5678 ); fields.putInt( "Int3", 0 );
MQeStringHndl hFieldName; rc = mqeString_newChar8(&errStruct, &hFieldName, "A Field Name"); rc = mqeFields_putInt32(hNewFields,&errStruct,hFieldName,1234);
The following example shows how to retrieve values from an MQeFields item:
/* Retrieve an integer value from a fields object */ int Int2 = fields.getInt( "Int2" );
MQEINT32 value; rc = mqeFields_getInt32(hNewFields, &errStruct, &value, hFieldName);
WebSphere MQ Everyplace provides methods for storing and retrieving the following data types:
An MQeFields item may be embedded within another MQeFields item by using the putFields and getFields methods.
The contents of an MQeFields item can be dumped in one of the following forms:
When a fixed length array is dumped and the array does not contain any elements (its length is zero), its value is restored as null.
"(#0)#1=#2\r\n"
where
Any other characters are copied unchanged to the output string. The method successfully dumps embedded MQeFields objects to a string, but due to restrictions, the embedded MQeFields data may not be restored using the restoreFromString method.