/** * Serialize outbound message. * * @param outboundMessageSource Represent the outbound message datasource * @param entity Represent the entity of the outbound message * @param messageOutputStream Represent the output stream * @throws IOException In case an error occurs while writing to output stream */ public static void serializeDataSource(BValue outboundMessageSource, BMap<String, BValue> entity, OutputStream messageOutputStream) throws IOException { if (MimeUtil.generateAsJSON(outboundMessageSource, entity)) { JsonGenerator gen = new JsonGenerator(messageOutputStream); gen.serialize(outboundMessageSource); gen.flush(); } else { outboundMessageSource.serialize(messageOutputStream); } }