Flink 程序消费多个 Topic 的数据,需要根据不同的 Topic 走不同的处理逻辑,仔细分析这个需求,实际上可以分为两个小问题:
关于第一个问题,获取 Kafka 的 Topic 信息,我们可以直接使用 Flink 内置的反序列类 JSONKeyValueDeserializationSchema 来获取,但是我们通常不会选择使用它,为什么呢?我们先来看下它的源码就明白了。
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file