2

While building a grails 3.3.9 application, I've encountered a scenario where I need to call its own API on application restart (for a specific purpose). I long as I know we can't make an API calls via boostrap.groovy, So an alternate option I found the Application.main method from where I can make own API calls. But this is only working on Grails - run mode. I need to make this working on Grails - war mode-as I have to deploy the war in the production environment once it verified in QC.

I can have the cron setup to do this but I am looking for the grails inbuilt function.

Others information: Grails:3.3.9 Gradle:4.10.3 Tomcat 8.5.50

  • if by "API calls" you mean making a method call on some library api, that can most definitely be done in BootStrap.groovy. Any valid Groovy code may be included there. If you mean have the application make an HTTP request to itself, if you can summarize why you need that, that might shed some light on another option. – Jeff Scott Brown Jul 13 '20 at 16:02
  • @JeffScottBrown sorry for the confusion, Not exactly the request to itself but something similar to that. I need to make the HTTP calls to another internal application from the current application on application restart and after request reach to that internal application, that again initiate the HTTP post call to request initiator for the response data. (You may have a question why not to send the whole data as a response on first request but we have security reason to do so ) – Ramesh Sapkota Jul 13 '20 at 16:18
  • Why can't you do that from `BootStrap.groovy`? – Jeff Scott Brown Jul 13 '20 at 16:26
  • 1
    Because the application could not be ready unit it finishes the **BootStrap.groovy** jobs. And causing the HTTP timeout while making HTTP calls from second application. – Ramesh Sapkota Jul 13 '20 at 16:42
  • I don't think I can help. Apologies. Best of luck! – Jeff Scott Brown Jul 13 '20 at 16:44
  • No problem. Thanks for your response. – Ramesh Sapkota Jul 13 '20 at 16:47

0 Answers0