Class MongoSinkBuilder<T>

    • Field Detail

      • DEFAULT_TRANSACTION_OPTION

        public static final com.mongodb.TransactionOptions DEFAULT_TRANSACTION_OPTION
        Default transaction options used by the processors.
      • DEFAULT_COMMIT_RETRY_STRATEGY

        public static final RetryStrategy DEFAULT_COMMIT_RETRY_STRATEGY
        Default retry strategy used by the processors.
    • Method Detail

      • into

        @Nonnull
        public MongoSinkBuilder<T> into​(@Nonnull
                                        FunctionEx<T,​java.lang.String> selectDatabaseNameFn,
                                        @Nonnull
                                        FunctionEx<T,​java.lang.String> selectCollectionNameFn)
        Parameters:
        selectDatabaseNameFn - selects database name for each item individually
        selectCollectionNameFn - selects collection name for each item individually
      • into

        @Nonnull
        public MongoSinkBuilder<T> into​(@Nonnull
                                        java.lang.String databaseName,
                                        @Nonnull
                                        java.lang.String collectionName)
        Parameters:
        databaseName - database name to which objects will be inserted/updated.
        collectionName - collection name to which objects will be inserted/updated.
      • withCustomReplaceOptions

        @Nonnull
        public MongoSinkBuilder<T> withCustomReplaceOptions​(@Nonnull
                                                            ConsumerEx<com.mongodb.client.model.ReplaceOptions> adjustConsumer)
        Provides an option to adjust options used in replace action. By default upsert is only enabled.
      • identifyDocumentBy

        @Nonnull
        public MongoSinkBuilder<T> identifyDocumentBy​(@Nonnull
                                                      java.lang.String fieldName,
                                                      @Nonnull
                                                      FunctionEx<T,​java.lang.Object> documentIdentityFn)
        Sets the filter that decides which document in the collection is equal to processed document.
        Parameters:
        fieldName - field name in the collection, that will be used for comparison
        documentIdentityFn - function that extracts ID from given item; will be compared against fieldName
      • checkResourceExistence

        @Nonnull
        public MongoSinkBuilder<T> checkResourceExistence​(ResourceChecks checkResourceExistence)
        If ResourceChecks.NEVER, the database and collection will be automatically created on the first usage. Otherwise, querying for a database or collection that don't exist will cause an error. Default value is ResourceChecks.ONCE_PER_JOB.
        Parameters:
        checkResourceExistence - mode of resource existence checks; whether exception should be thrown when database or collection does not exist and when the check will be performed.
        Since:
        5.4
      • build

        @Nonnull
        public Sink<T> build()
        Creates and returns the MongoDB Sink with the components you supplied to this builder.