IN - Type of the elements handled by this sink@PublicEvolving public class MongoSink<IN> extends Object implements org.apache.flink.api.connector.sink2.Sink<IN>
WriteModel (bulk write action) and
bulk writes to mongodb when the number of actions is greater than batchSize or the flush interval
is greater than batchIntervalMs.
The following example shows how to create a MongoSink sending records of Document
type.
MongoSink<Document> sink = MongoSink.<Document>builder()
.setUri("mongodb://user:password@127.0.0.1:27017")
.setDatabase("db")
.setCollection("coll")
.setBatchSize(5)
.setSerializationSchema(
(doc, context) -> new InsertOneModel<>(doc.toBsonDocument()))
.build();
| 限定符和类型 | 方法和说明 |
|---|---|
static <IN> MongoSinkBuilder<IN> |
builder() |
org.apache.flink.api.connector.sink2.SinkWriter<IN> |
createWriter(org.apache.flink.api.connector.sink2.Sink.InitContext context) |
public static <IN> MongoSinkBuilder<IN> builder()
Copyright © 2022–2024 The Apache Software Foundation. All rights reserved.