use of com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer 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();
}
use of com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer in project eventuate-local by eventuate-local.
the class MySqlBinaryLogClient method getEventDeserializer.
private EventDeserializer getEventDeserializer() {
EventDeserializer eventDeserializer = new EventDeserializer();
// do not deserialize binlog events except the EXT_WRITE_ROWS and TABLE_MAP
Arrays.stream(EventType.values()).forEach(eventType -> {
if (eventType != EventType.EXT_WRITE_ROWS && eventType != EventType.TABLE_MAP && eventType != EventType.ROTATE) {
eventDeserializer.setEventDataDeserializer(eventType, new NullEventDataDeserializer());
}
});
eventDeserializer.setEventDataDeserializer(EventType.EXT_WRITE_ROWS, new WriteRowsEventDataDeserializer(tableMapEventByTableId).setMayContainExtraInformation(true));
return eventDeserializer;
}
use of com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer in project debezium by debezium.
the class ReadBinLogIT method startClient.
protected void startClient(Consumer<BinaryLogClient> preConnect) throws IOException, TimeoutException, SQLException {
// Connect the bin log client ...
counters = new EventQueue(DEFAULT_TIMEOUT, this::logConsumedEvent, this::logIgnoredEvent);
client = new BinaryLogClient(config.getHostname(), config.getPort(), "replicator", "replpass");
// avoid clashes between BinaryLogClient instances
client.setServerId(client.getServerId() - 1);
client.setKeepAlive(false);
client.setSSLMode(SSLMode.DISABLED);
client.registerEventListener(counters);
client.registerEventListener(this::recordEvent);
client.registerLifecycleListener(new TraceLifecycleListener());
EventDeserializer eventDeserializer = new EventDeserializer();
eventDeserializer.setEventDataDeserializer(EventType.STOP, new StopEventDataDeserializer());
client.setEventDeserializer(eventDeserializer);
if (preConnect != null)
preConnect.accept(client);
// does not block
client.connect(DEFAULT_TIMEOUT);
// Set up the table as one transaction and wait to see the events ...
conn.execute("DROP TABLE IF EXISTS person", "CREATE TABLE person (" + " name VARCHAR(255) primary key," + " age INTEGER NULL DEFAULT 10," + " createdAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP," + " updatedAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + ")");
counters.consume(2, EventType.QUERY);
counters.reset();
}
Aggregations