我的 FlinkKafkaProducer011 需要的参数比应该的要少。

huangapple go评论79阅读模式
英文:

My FlinkKafkaProducer011 needs fewer arguments than is supposed to

问题

I’m having difficulties with FlinkKafkaConnector.

虽然我已经导入了org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011,但我收到了以下错误消息。

构造函数FlinkKafkaProducer011有太多参数

根据此网站,参数是正确的。然而,我的IntelliJ显示如下定义。

public FlinkKafkaProducer011() {
}

有人知道如何修复吗?

我的 FlinkKafkaProducer011 需要的参数比应该的要少。

更新

这是IDE的定义。

public class FlinkKafkaProducer011 {
    public FlinkKafkaProducer011() {
    }

    public static class NextTransactionalIdHint extends org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint {
        public NextTransactionalIdHint() {
        }
    }

    public static class TransactionStateSerializer {
        public TransactionStateSerializer() {
        }

        public static final class TransactionStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionState> {
            public TransactionStateSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.TransactionStateSerializer::new);
            }
        }
    }

    public static class ContextStateSerializer {
        public ContextStateSerializer() {
        }

        public static final class ContextStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionContext> {
            public ContextStateSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.ContextStateSerializer::new);
            }
        }
    }

    public static class NextTransactionalIdHintSerializer {
        public NextTransactionalIdHintSerializer() {
        }

        public static final class NextTransactionalIdHintSerializerSnapshot extends SimpleTypeSerializerSnapshot<org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint> {
            public NextTransactionalIdHintSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHintSerializer::new);
            }
        }
    }
}
英文:

I’m having difficulties with FlinkKafkaConnector.

Although I have imported the org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011, I got the following error.

Too many arguments for constructor FlinkKafkaProducer011

According to this site, the arguments are correct. However, my IntelliJ shows this definition.

public FlinkKafkaProducer011() {
}

Does anyone know how to fix it?

我的 FlinkKafkaProducer011 需要的参数比应该的要少。

UPDATE

Here is the IDE definition.

public class FlinkKafkaProducer011 {
    public FlinkKafkaProducer011() {
    }

    public static class NextTransactionalIdHint extends org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint {
        public NextTransactionalIdHint() {
        }
    }

    public static class TransactionStateSerializer {
        public TransactionStateSerializer() {
        }

        public static final class TransactionStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionState> {
            public TransactionStateSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.TransactionStateSerializer::new);
            }
        }
    }

    public static class ContextStateSerializer {
        public ContextStateSerializer() {
        }

        public static final class ContextStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionContext> {
            public ContextStateSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.ContextStateSerializer::new);
            }
        }
    }

    public static class NextTransactionalIdHintSerializer {
        public NextTransactionalIdHintSerializer() {
        }

        public static final class NextTransactionalIdHintSerializerSnapshot extends SimpleTypeSerializerSnapshot<org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint> {
            public NextTransactionalIdHintSerializerSnapshot() {
                super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHintSerializer::new);
            }
        }
    }
}

答案1

得分: 2

请问您使用的是flink-connector-kafka的哪个版本?

根据我所看到的情况,您使用的org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011只是flink-connector-kafka_2.11 JAR包的兼容性类,正确的生产者应该是org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer

据我了解,这里的Java文档适用于flink-connector-kafka-0.11_2.11版本的org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011生产者。

因此,我建议要么切换到org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer,要么将依赖项更改为flink-connector-kafka-0.11_2.11 JAR包。

英文:

Could you please specify what flink-connector-kafka version you use ?

From what I can see, the org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011 you have used is just a compatibility class from flink-connector-kafka_2.11 jar and the right producer to use is org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.

As far as I understand, the javadoc https://ci.apache.org/projects/flink/flink-docs-release-1.4/api/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer011.html is relevant for org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011 producer from flink-connector-kafka-0.11_2.11 artifact.

So, I would suggest to either switch to org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer or change dependency to flink-connector-kafka-0.11_2.11 jar.

huangapple
  • 本文由 发表于 2020年8月11日 16:32:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63354439.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定