I’m trying to run an API that uses mongo for ES and query repo. I’m getting the following error (at the bottom of this log):
Aug 03, 2017 7:12:06 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Aug 03, 2017 7:12:06 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.16
Aug 03, 2017 7:12:07 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout=‘30000 ms’, maxWaitQueueSize=500}
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Adding discovered server localhost:27017 to client view of cluster
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:1, serverValue:1}] to localhost:27017
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 6]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, roundTripTimeNanos=714906}
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Discovered cluster type of STANDALONE
Aug 03, 2017 7:12:08 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:2, serverValue:2}] to localhost:27017
Aug 03, 2017 7:12:12 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Closed connection [connectionId{localValue:2, serverValue:2}] to localhost:27017 because the pool has been closed.
Aug 03, 2017 7:12:12 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service [Tomcat]
Process finished with exit code 1
The connection to mongo is successfully established. In RoboMongo I can see the new database it creates, the events and snapshot collections. But then API exits…
Here’s my config files:
@Configuration
public class EventStoreConfig {
@Value("${mongodb.host}")
private String mongoHost;
@Value("${mongodb.db.name}")
private String mongoDbName;
@Value("${mongodb.events.collection.name}")
private String eventsCollectionName;
@Value("${mongodb.events.snapshot.collection.name}")
private String snapshotCollectionName;
@Bean
public Serializer axonJsonSerializer() {
return new JacksonSerializer();
}
@Bean
public EventStorageEngine eventStorageEngine(){
return new MongoEventStorageEngine(
axonJsonSerializer(),null, axonMongoTemplate(), new DocumentPerEventStorageStrategy());
}
@Bean(name = "axonMongoTemplate")
public MongoTemplate axonMongoTemplate() {
MongoTemplate template = new DefaultMongoTemplate(mongoClient(), mongoDbName, eventsCollectionName, snapshotCollectionName);
return template;
}
@Bean
public MongoClient mongoClient(){
MongoFactory mongoFactory = new MongoFactory();
mongoFactory.setMongoAddresses(Arrays.asList(new ServerAddress(mongoHost)));
// This didn't help :(
//MongoClientOptions options = new MongoClientOptions.Builder().socketKeepAlive(true).build();
//
//mongoFactory.setMongoOptions(options);
return mongoFactory.createMongo();
}
}