Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SinkConfig.js message value null #49

Open
vuongwphamj opened this issue Feb 20, 2020 · 1 comment
Open

SinkConfig.js message value null #49

vuongwphamj opened this issue Feb 20, 2020 · 1 comment

Comments

@vuongwphamj
Copy link

class SinkConfig

static _messageToRecord(message) {

        //check if a converter has already turned this message into a record
        if (message && typeof message.value === "object" &&
            message instanceof SinkRecord) {
            return message;
        }

        try {
            const record = new SinkRecord();

            record.kafkaOffset = message.offset;
            record.key = message.key;
            record.partition = message.partition;

            record.keySchema = message.value.keySchema;
            record.timestamp = message.value.timestamp;
            record.value = message.value.value;
            record.valueSchema = message.value.valueSchema;

            return record;
        } catch (error) {
            debug("Failed to turn message into sink record.", error.message);
            super.emit("error", "Failed to turn message into SinkRecord: " + error.message);
            return message;
        }
    }
@vuongwphamj
Copy link
Author

 static _messageToRecord(message) {
        //check if a converter has already turned this message into a record
        if (message && typeof message.value === "object" &&
            message instanceof SinkRecord) {

            return message;
        }

        try {
            const record = new SinkRecord();

// fix in here
            const msgTemp = JSON.parse(message.value.toString());
            const msgValue = JSON.parse(msgTemp);

            record.kafkaOffset = message.offset;
            record.key = message.key;
            record.partition = message.partition;

            record.keySchema = msgValue.keySchema;
            record.timestamp = msgValue.timestamp;
            record.value = msgValue.value;
            record.valueSchema = msgValue.valueSchema;

            return record;
        } catch (error) {
            debug("Failed to turn message into sink record.", error.message);
            super.emit("error", "Failed to turn message into SinkRecord: " + error.message);
            return message;
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant