Reduce MongoDB Thread ttl time

The issue is reducing MongoDB thread monitoring time in java .
I would like to run component test code as stated below. For the component test I would like to make asleep(at most 30 sec not 1 minute) and check if expired documents are removed or not. But it doesnt work. If I run thread.sleep(60000) (1 minute) It works but it is too much delay for a component test. Do you have any solution for this?
‘’’
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorEnabled”, new BsonBoolean(false)));
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorSleepSecs”, new BsonInt64(5)));
runCommand(new BsonDocument(“setParameter”, new BsonInt32(1)).append(“ttlMonitorEnabled”, new BsonBoolean(true)));
Thread.sleep(15000);
long afterCount = getCounter(TrainedDbModel.class);

// then
assertThat(afterCount).isEqualTo(1);
public void runCommand(final Bson command) {
final MongoDatabase db = mongoClient.getDatabase(“admin”);
db.runCommand(command);
}
‘’’

Hi @seda_tankiz

I believe this is the same question as in Reduce/chance Mongodb TTL time (60 seconds) in java - #4 by seda_tankiz ?

I have provided a reply in that thread, hope it helps.

Best regards
Kevin

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.