Apama 10.15.0 | Connecting Apama Applications to External Components | Correlator-Integrated Support for the Java Message Service (JMS) | Using the Java Message Service (JMS) | Mapping Apama events and JMS messages | Handling binary data
 
Handling binary data
JUEL mapping expressions can use the following methods on binary data.
The byteArrayToBase64() method takes a byte array as the input parameter and returns the Base64 encoded string. Following is an example of mapping byte array data to a Base64-encoded string, which can be mapped to an Apama string field.
${byteArrayToBase64(jms.body.bytesmessage)}
The base64ToByteArray() method takes a Base64-encoded string as an input parameter and returns a byte array. For example:
${base64ToByteArray(apamaEvent['body'])}
The javaObjectToByteArray() method takes a serializable Java object as the input parameter and returns a serialized byte array. In the following example, the body of jms.objectmessage is serialized into a byte array, the byte array is then encoded into a Base64-encoded string, and that string can be mapped to a string field in an Apama event.
${byteArrayToBase64(javaObjectToByteArray(jms.body.objectmessage))}
The byteArrayToJavaObject() method takes a byte array as the input parameter and returns a deserialized Java object. In the following example, the string field of an Apama event, which is a Base64-encoded string, is converted into a byte array. The byte array is then deserialized into a Java object and can be mapped, for example, to the body of jms.objectmessage.
${byteArrayToJavaObject(base64ToByteArray(apamaEvent['body']))}
These binary methods can be used by creating custom expressions. In the Event Mappings tab, right-click a <Custom> node and select Add Node to display the Add Node dialog.
Note: 
In these binary methods, if the argument passed to the method is null or empty then the method returns null. If a null value would be set for a field in an Apama event then the field is set to the default value for the field's type, for example, a string field is set to the empty string, "".