Search in sources :

Example 1 with MySqlSourceBuilder

use of com.ververica.cdc.connectors.base.experimental.MySqlSourceBuilder in project flink-cdc-connectors by ververica.

the class MySqlChangeEventSourceExampleTest method testConsumingAllEvents.

@Test
@Ignore("Test ignored because it won't stop and is used for manual test")
public void testConsumingAllEvents() throws Exception {
    inventoryDatabase.createAndInitialize();
    JdbcIncrementalSource<String> mySqlChangeEventSource = new MySqlSourceBuilder().hostname(MYSQL_CONTAINER.getHost()).port(MYSQL_CONTAINER.getDatabasePort()).databaseList(inventoryDatabase.getDatabaseName()).tableList(inventoryDatabase.getDatabaseName() + ".products").username(inventoryDatabase.getUsername()).password(inventoryDatabase.getPassword()).serverId("5401-5404").deserializer(new JsonDebeziumDeserializationSchema()).includeSchemaChanges(// output the schema changes as well
    true).build();
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    // enable checkpoint
    env.enableCheckpointing(3000);
    // set the source parallelism to 4
    env.fromSource(mySqlChangeEventSource, WatermarkStrategy.noWatermarks(), "MySqlParallelSource").setParallelism(4).print().setParallelism(1);
    env.execute("Print MySQL Snapshot + Binlog");
}
Also used : MySqlSourceBuilder(com.ververica.cdc.connectors.base.experimental.MySqlSourceBuilder) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) JsonDebeziumDeserializationSchema(com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

MySqlSourceBuilder (com.ververica.cdc.connectors.base.experimental.MySqlSourceBuilder)1 JsonDebeziumDeserializationSchema (com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1