Skip to content

Instantly share code, notes, and snippets.

@egcodes
Created March 9, 2022 07:39
Show Gist options
  • Save egcodes/288ab0b0293c355097c363e55268a59f to your computer and use it in GitHub Desktop.
Save egcodes/288ab0b0293c355097c363e55268a59f to your computer and use it in GitHub Desktop.
@Configuration
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ShedlockMongoConfiguration {
private final MongoFactory mongoFactory;
private final MongoReplicaSetFactory mongoReplicaSetFactory;
@Value("${sahibinden.mongodb.dbs.sahibinden.replicaSetName}")
private String mongoReplicaSetName;
@Bean
public LockProvider lockProvider() {
var mongoClient = (MongoClient) this.mongoReplicaSetFactory.getMongo(mongoReplicaSetName);
return new MongoLockProvider(mongoClient.getDatabase(mongoFactory.getDatabaseName()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment