Search in sources :

Example 6 with JsonDebeziumDeserializationSchema

use of com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema in project flink-cdc-connectors by ververica.

the class MySqlSourceExampleTest method testConsumingAllEvents.

@Test
@Ignore("Test ignored because it won't stop and is used for manual test")
public void testConsumingAllEvents() throws Exception {
    inventoryDatabase.createAndInitialize();
    MySqlSource<String> mySqlSource = MySqlSource.<String>builder().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(mySqlSource, WatermarkStrategy.noWatermarks(), "MySqlParallelSource").setParallelism(4).print().setParallelism(1);
    env.execute("Print MySQL Snapshot + Binlog");
}
Also used : StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) JsonDebeziumDeserializationSchema(com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

JsonDebeziumDeserializationSchema (com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema)6 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Properties (java.util.Properties)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 JSONObject (com.alibaba.fastjson.JSONObject)1 MySqlSourceBuilder (com.ververica.cdc.connectors.base.experimental.MySqlSourceBuilder)1 OracleSource (com.ververica.cdc.connectors.oracle.OracleSource)1 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 TableResult (org.apache.flink.table.api.TableResult)1 StreamTableEnvironment (org.apache.flink.table.api.bridge.java.StreamTableEnvironment)1 Row (org.apache.flink.types.Row)1