Search in sources :

Example 1 with Schema

use of org.apache.rocketmq.mysql.schema.Schema in project rocketmq-externals by apache.

the class EventProcessor method start.

public void start() throws Exception {
    initDataSource();
    binlogPositionManager = new BinlogPositionManager(config, dataSource);
    binlogPositionManager.initBeginPosition();
    schema = new Schema(dataSource);
    schema.load();
    eventListener = new EventListener(queue);
    binaryLogClient = new BinaryLogClient(config.mysqlAddr, config.mysqlPort, config.mysqlUsername, config.mysqlPassword);
    binaryLogClient.setBlocking(true);
    binaryLogClient.setServerId(1001);
    EventDeserializer eventDeserializer = new EventDeserializer();
    eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG, EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY);
    binaryLogClient.setEventDeserializer(eventDeserializer);
    binaryLogClient.registerEventListener(eventListener);
    binaryLogClient.setBinlogFilename(binlogPositionManager.getBinlogFilename());
    binaryLogClient.setBinlogPosition(binlogPositionManager.getPosition());
    binaryLogClient.connect(3000);
    LOGGER.info("Started.");
    doProcess();
}
Also used : Schema(org.apache.rocketmq.mysql.schema.Schema) EventDeserializer(com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer) BinlogPositionManager(org.apache.rocketmq.mysql.position.BinlogPositionManager) BinaryLogClient(com.github.shyiko.mysql.binlog.BinaryLogClient)

Aggregations

BinaryLogClient (com.github.shyiko.mysql.binlog.BinaryLogClient)1 EventDeserializer (com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer)1 BinlogPositionManager (org.apache.rocketmq.mysql.position.BinlogPositionManager)1 Schema (org.apache.rocketmq.mysql.schema.Schema)1