Reputation: 580
I have a Spring3 web-app running on tomcat7. http://www.mkyong.com/mongodb/spring-data-mongodb-hello-world-example/, I have followed this tutorial and then I have a @Scheduled method that runs every ten second. In this method it opens a mongo connection with MongoOperations mongoOperation = (MongoOperations)ctx.getBean("mongoTemplate");
My problem now is that I dont know how to close the connections and every ten second a new process/thread is spawned in tomcat.. so I think you can imagine the problem. Does anyone have any idea how to solve this?
Upvotes: 1
Views: 3252
Reputation: 580
Solved by replacing MongoOperations with the implementation MongoTemplate and then on the MongoTemplate call mongoTemplate.getDb().getMongo().close();
Upvotes: 4