Class MongoSink

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

    public class MongoSink
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      MongoSink()  
      MongoSink​(java.util.function.Supplier<com.mongodb.reactivestreams.client.MongoClient> clientProvider)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void open​(java.util.Map<java.lang.String,​java.lang.Object> config, org.apache.pulsar.io.core.SinkContext sinkContext)  
      void write​(org.apache.pulsar.functions.api.Record<byte[]> record)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MongoSink

        public MongoSink()
      • MongoSink

        public MongoSink​(java.util.function.Supplier<com.mongodb.reactivestreams.client.MongoClient> clientProvider)
    • Method Detail

      • open

        public void open​(java.util.Map<java.lang.String,​java.lang.Object> config,
                         org.apache.pulsar.io.core.SinkContext sinkContext)
                  throws java.lang.Exception
        Specified by:
        open in interface org.apache.pulsar.io.core.Sink<byte[]>
        Throws:
        java.lang.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 java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception