Skip to content

Commit 1143a9b

Browse files
author
Norman Maurer
committed
Merge pull request #24 from zilet/master
autoConnectRetry Mongo option added
2 parents a5d7a19 + ef036a3 commit 1143a9b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/org/vertx/mods/MongoPersistor.java

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class MongoPersistor extends BusModBase implements Handler<Message<JsonOb
4242
protected String dbName;
4343
protected String username;
4444
protected String password;
45+
protected boolean autoConnectRetry;
46+
protected int socketTimeout;
4547

4648
protected Mongo mongo;
4749
protected DB db;
@@ -57,10 +59,14 @@ public void start() {
5759
username = getOptionalStringConfig("username", null);
5860
password = getOptionalStringConfig("password", null);
5961
int poolSize = getOptionalIntConfig("pool_size", 10);
62+
autoConnectRetry = getOptionalBooleanConfig("autoConnectRetry", true);
63+
socketTimeout = getOptionalIntConfig("socketTimeout", 60000);
6064

6165
try {
6266
MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
6367
builder.connectionsPerHost(poolSize);
68+
builder.autoConnectRetry(autoConnectRetry);
69+
builder.socketTimeout(socketTimeout);
6470
ServerAddress address = new ServerAddress(host, port);
6571
mongo = new MongoClient(address, builder.build());
6672
db = mongo.getDB(dbName);

0 commit comments

Comments
 (0)