Package com.hazelcast.jet.mongodb
Class MongoSinkBuilder<T>
java.lang.Object
com.hazelcast.jet.mongodb.MongoSinkBuilder<T>
- Type Parameters:
T- type of the items the sink will accept
- Since:
- 5.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RetryStrategyDefault retry strategy used by the processors.static final com.mongodb.TransactionOptionsDefault transaction options used by the processors. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates and returns the MongoDBSinkwith the components you supplied to this builder.checkResourceExistence(ResourceChecks checkResourceExistence) IfResourceChecks.NEVER, the database and collection will be automatically created on the first usage.commitRetryStrategy(RetryStrategy commitRetryStrategy) Sets the retry strategy in case of commit failure.identifyDocumentBy(String fieldName, FunctionEx<T, Object> documentIdentityFn) Sets the filter that decides which document in the collection is equal to processed document.into(FunctionEx<T, String> selectDatabaseNameFn, FunctionEx<T, String> selectCollectionNameFn) preferredLocalParallelism(int preferredLocalParallelism) transactionOptions(SupplierEx<com.mongodb.TransactionOptions> transactionOptionsSup) Sets options which will be used by MongoDB transaction mechanism.withCustomReplaceOptions(ConsumerEx<com.mongodb.client.model.ReplaceOptions> adjustConsumer) Provides an option to adjust options used in replace action.Sets write mode used by the connector.
-
Field Details
-
DEFAULT_TRANSACTION_OPTION
public static final com.mongodb.TransactionOptions DEFAULT_TRANSACTION_OPTIONDefault transaction options used by the processors. -
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 individuallyselectCollectionNameFn- 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
-
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 comparisondocumentIdentityFn- function that extracts ID from given item; will be compared againstfieldName
-
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
Sets write mode used by the connector. Default value is WriteMode.REPLACE. -
checkResourceExistence
IfResourceChecks.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 isResourceChecks.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
Creates and returns the MongoDBSinkwith the components you supplied to this builder.
-