modules/ballerina-native/src/main/java/org/ballerinalang/nativeimpl/connectors/jms/utils/JMSMessageUtils.java
public static SerializableCarbonMessage toSerializableCarbonMessage(BMessage message) {
        SerializableCarbonMessage serializableCarbonMessage = new SerializableCarbonMessage();

        List<Header> headers = message.getHeaders();
        HashMap<String, String> headerMap = new HashMap<>();
        for (Header header : headers) {
            headerMap.put(header.getName(), header.getValue());
        }
        serializableCarbonMessage.setHeaders(headerMap);
        if (headerMap.containsKey(Constants.CONTENT_TYPE)) {
            if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.APPLICATION_JSON)) {
                serializableCarbonMessage.setPayload(getJsonPayload(message));
            } else if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.APPLICATION_XML)) {
                serializableCarbonMessage.setPayload(getXmlPayload(message));
            } else if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.TEXT_PLAIN)) {
                serializableCarbonMessage.setPayload(getStringPayload(message));
            }
        }

        return serializableCarbonMessage;
    }
/**
     * To convert a {@link BMessage} message into a {@link SerializableCarbonMessage}.
     *
     * @param message {@link BMessage} to be converted
     * @return Converted {@link SerializableCarbonMessage}
     */
To convert a  BMessage message into a  SerializableCarbonMessage.
@param message  BMessage to be converted
@return Converted  SerializableCarbonMessage
To convert a BMessage message into a SerializableCarbonMessage . @param message BMessage to be converted @return Converted SerializableCarbonMessage
public static SerializableCarbonMessage toSerializableCarbonMessage(BMessage message) {
        SerializableCarbonMessage serializableCarbonMessage = new SerializableCarbonMessage();
        List<Header> headers = message.getHeaders();
        HashMap<String, String> headerMap = new HashMap<>();
        for (Header header : headers) {
            headerMap.put(header.getName(), header.getValue());
        }
        serializableCarbonMessage.setHeaders(headerMap);
        if (headerMap.containsKey(Constants.CONTENT_TYPE)) {
            if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.APPLICATION_JSON)) {
                serializableCarbonMessage.setPayload(getJsonPayload(message));
            } else if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.APPLICATION_XML)) {
                serializableCarbonMessage.setPayload(getXmlPayload(message));
            } else if (headerMap.get(Constants.CONTENT_TYPE).equals(Constants.TEXT_PLAIN)) {
                serializableCarbonMessage.setPayload(getStringPayload(message));
            }
        }
        return serializableCarbonMessage;
    }
public static SerializableCarbonMessage toSerializableCarbonMessage ( BMessage message ) { SerializableCarbonMessage serializableCarbonMessage = new SerializableCarbonMessage ( ) ; List < Header > headers = message . getHeaders ( ) ; HashMap < String , String > headerMap = new HashMap < > ( ) ; for ( Header header : headers ) { headerMap . put ( header . getName ( ) , header . getValue ( ) ) ; } serializableCarbonMessage . setHeaders ( headerMap ) ; if ( headerMap . containsKey ( Constants . CONTENT_TYPE ) ) { if ( headerMap . get ( Constants . CONTENT_TYPE ) . equals ( Constants . APPLICATION_JSON ) ) { serializableCarbonMessage . setPayload ( getJsonPayload ( message ) ) ; } else if ( headerMap . get ( Constants . CONTENT_TYPE ) . equals ( Constants . APPLICATION_XML ) ) { serializableCarbonMessage . setPayload ( getXmlPayload ( message ) ) ; } else if ( headerMap . get ( Constants . CONTENT_TYPE ) . equals ( Constants . TEXT_PLAIN ) ) { serializableCarbonMessage . setPayload ( getStringPayload ( message ) ) ; } } return serializableCarbonMessage ; }
To convert a {@link BMessage} message into a {@link SerializableCarbonMessage}.
To convert a { @link BMessage } message into a { @link SerializableCarbonMessage } .