|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.mongo3.eventstore.MongoFactory
public class MongoFactory
Convenience class for creating Mongo instances. It helps configuring a Mongo instance with a WriteConcern safe to use in combination with the given server addresses.
Depending on the number of addresses provided, the factory defaults to eitherWriteConcern.REPLICAS_SAFE
when more than one address is provided, or WriteConcern.FSYNC_SAFE
when only one server is available. The
idea of these defaults is that data must be able to survive a (not too heavy) crash without loss of data. We
wouldn't want to publish untraceable events, would we...
Constructor Summary | |
---|---|
MongoFactory()
|
Method Summary | |
---|---|
com.mongodb.MongoClient |
createMongo()
Creates a mongo instance based on the provided configuration. |
void |
setMongoAddresses(List<com.mongodb.ServerAddress> mongoAddresses)
Provide a list of ServerAddress objects to use for locating the Mongo replica set. |
void |
setMongoOptions(com.mongodb.MongoClientOptions mongoOptions)
Provide an instance of MongoOptions to be used for the connections. |
void |
setWriteConcern(com.mongodb.WriteConcern writeConcern)
Provided a write concern to be used by the mongo instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MongoFactory()
Method Detail |
---|
public com.mongodb.MongoClient createMongo()
public void setMongoAddresses(List<com.mongodb.ServerAddress> mongoAddresses)
127.0.0.1
) and port
(com.mongodb.ServerAddress#defaultPort
)
Defaults to an empty list, which locates a single Mongo instance on the default host (127.0.0.1
)
and port (com.mongodb.ServerAddress#defaultPort
)
mongoAddresses
- List of ServerAddress instancespublic void setMongoOptions(com.mongodb.MongoClientOptions mongoOptions)
mongoOptions
- MongoOptions to overrule the defaultpublic void setWriteConcern(com.mongodb.WriteConcern writeConcern)
setMongoAddresses(java.util.List)
. For example, providing
WriteConcern.REPLICAS_SAFE
in combination with a single address will cause each write operation to hang.
While safe (e.g. WriteConcern.REPLICAS_SAFE
) WriteConcerns allow you to detect concurrency issues
immediately, you might want to use a more relaxed write concern if you have other mechanisms in place to ensure
consistency.
Defaults to WriteConcern.REPLICAS_SAFE
if you provided more than one address with
setMongoAddresses(java.util.List)
, or WriteConcern.FSYNC_SAFE
if there is only one address (or
none at all).
writeConcern
- WriteConcern to use for the connections
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |