Class MongoSinkBuilder<T>

java.lang.Object
com.hazelcast.jet.mongodb.MongoSinkBuilder<T>
Type Parameters:
T - type of the items the sink will accept

public final class MongoSinkBuilder<T> extends Object
Since:
5.3
  • Field Details

    • 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 Details

    • into

      @Nonnull public MongoSinkBuilder<T> into(@Nonnull FunctionEx<T,String> selectDatabaseNameFn, @Nonnull FunctionEx<T,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 String databaseName, @Nonnull String collectionName)
      Parameters:
      databaseName - database name to which objects will be inserted/updated.
      collectionName - collection name to which objects will be inserted/updated.
    • preferredLocalParallelism

      @Nonnull public MongoSinkBuilder<T> preferredLocalParallelism(int preferredLocalParallelism)
    • 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 String fieldName, @Nonnull FunctionEx<T,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
    • commitRetryStrategy

      @Nonnull public MongoSinkBuilder<T> commitRetryStrategy(@Nonnull RetryStrategy commitRetryStrategy)
      Sets the retry strategy in case of commit failure.

      MongoDB by default retries simple operations, but commits must be retried manually.

      This option is taken into consideration only if ProcessingGuarantee.EXACTLY_ONCE is used.

      Default value is DEFAULT_COMMIT_RETRY_STRATEGY.

    • transactionOptions

      @Nonnull public MongoSinkBuilder<T> transactionOptions(@Nonnull SupplierEx<com.mongodb.TransactionOptions> transactionOptionsSup)
      Sets options which will be used by MongoDB transaction mechanism.

      This option is taken into consideration only if ProcessingGuarantee.EXACTLY_ONCE is used.

      Default value is DEFAULT_TRANSACTION_OPTION.

    • writeMode

      @Nonnull public MongoSinkBuilder<T> writeMode(@Nonnull WriteMode writeMode)
      Sets write mode used by the connector. Default value is WriteMode.REPLACE.
      See Also:
    • 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.