I may suggest one of possible solutions, that is tested under the Mirth Connect v3.0. I’m hoping it should work under the v2.2 as well. Basically, you are moving on in the right direction, possible steps to complete are:
- On the JMS Sender side, create an instance of the object and populate required fields;
- Serialize the object (using org.apache.commons.lang3.SerializationUtils.serialize for example);
- Then encode the result (using the Mirth built-in Base64 encoder);
- Pass this to the destination connector which is configured as the JMS Sender.
On the receiver side do the same in a reverse order:
- Decode the received raw message (Base64 decoder);
- Deserialize the byte array into the object (using the org.apache.commons.lang3.SerializationUtils.deserialize);
- Access object’s fields.
Hope this helps.
(Ps. All steps described above in detail, with screenshots and code snippets, for a case where both sender and receiver are Mirth channels, are given in the “Unofficial Mirth Connect developer’s guide”. Disclaimer: I’m the author of this book so any comments or suggestions are welcome.)