Skip to content

chengjundong/imooc-flink

Repository files navigation

Problems you might encounter in Flink + ClickHouse

java.io.NotSerializableException in SinkFunction

// correct sink function
public class RedisT3Sink extends AbstractRichFunction implements SinkFunction<Tuple3<String, Integer, Long>> {

    private Jedis jedis;
    private final String hsetKey;

    public RedisT3Sink(String hsetKey) {
        this.hsetKey = hsetKey;
    }

    @Override
    public void open(Configuration parameters) {
        // use open method to create connection
        this.jedis = new Jedis("localhost", 6379);
    }
}

// wrong sink function
public class RedisT3Sink extends AbstractRichFunction implements SinkFunction<Tuple3<String, Integer, Long>> {

    private final Jedis jedis;
    private final String hsetKey;

    // while constructing, you will get java.io.NotSerializableException
    // because the impl of Jedis doesn't implement Serializable interface
    public RedisT3Sink(String hsetKey) {
        this.jedis = new Jedis("localhost", 6379);
        this.hsetKey = hsetKey;
    }

    @Override
    public void open(Configuration parameters) {}
}

reference

Run ClickHouse in WIN10, get "tzdata, key not found" error while connecting

Use ClickHouse version 20.x

About

慕课网,学习《Flink+ClickHouse 玩转企业级实时大数据开发》 https://coding.imooc.com/learn/list/510.html

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages