Converts the given message into the expected targetType.
Converts the given payload into a ByteArray.
Strings and primitives are converted directly, other types are serialized to json.