Class MongoSink

java.lang.Object
org.apache.pulsar.io.mongodb.MongoSink
All Implemented Interfaces:
AutoCloseable, org.apache.pulsar.io.core.Sink<byte[]>

public class MongoSink extends Object implements org.apache.pulsar.io.core.Sink<byte[]>
The base class for MongoDB sinks. Users need to implement extractKeyValue function to use this sink. This class assumes that the input will be JSON documents.
  • Constructor Details

    • MongoSink

      public MongoSink()
    • MongoSink

      public MongoSink(Supplier<com.mongodb.reactivestreams.client.MongoClient> clientProvider)
  • Method Details

    • open

      public void open(Map<String,Object> config, org.apache.pulsar.io.core.SinkContext sinkContext) throws Exception
      Specified by:
      open in interface org.apache.pulsar.io.core.Sink<byte[]>
      Throws:
      Exception
    • write

      public void write(org.apache.pulsar.functions.api.Record<byte[]> record)
      Specified by:
      write in interface org.apache.pulsar.io.core.Sink<byte[]>
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception