Grails Quartz MongoDB connections keep opening

I have a grails application that uses quartz to cycle through a domain class every 20 seconds.

Every time a quartz job is done, a different connection happens in Mongo. The previous ones do not close for some reason, so after 11 connections the work stops working (connection timeout). I tried a different approach, calling the url using the service methods called in the activity, but the number of connections keeps growing. When I repeatedly call the URL without doing the Quartz job, only 4 new connections are created and no more.

Any ideas how to do this?

Grails 2.1.2, MongoDB 1.1.0 Plugin, Quartz 1.0

+3


source to share


1 answer


For me it works with the following workaround: wrap your execution code in a call [SomeDomain].withNewSession { }

.

User

Domain example



def execute() {
   User.withNewSession {
      //your code
   }
}

      

+3


source







All Articles