开发者

How to execute a service once the Grails Server is ready

开发者 https://www.devze.com 2022-12-21 05:39 出处:网络
I have a Grails application which provides dummy webservices for itself. In the real world it could call webservices on another machine, but during development and testing we need be able to access th

I have a Grails application which provides dummy webservices for itself. In the real world it could call webservices on another machine, but during development and testing we need be able to access the internal webservice to populate tables. This can't be done during the bootstrap as the internal webserver has not started yet (Grails does this last).

So, I need to be able to detect that Grails has started the webserver, and then run a servi开发者_如何学编程ce to populate tables from the internal webservice.

I don't seem to find anything out there in googleland that appears to help...


One thing that comes to mind is to use a quartz job (with the quartz plugin), you can schedule a job as a one time event and just give it a short delay from when the server is finished starting to when it actually executes it.

class LoadDataJob {
   static triggers = {
       simple name: 'triggerName', startDelay: 5000   // wait for 5 seconds to run the job
   }

   def execute(){ /* loading code here */ } 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号