Announcement Announcement Module
Collapse
No announcement yet.
Invoking a web service when web server starts Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invoking a web service when web server starts

    This is probably a long shot but I thought I would check.

    Can Spring ping a localhost web services endpoint when my application is fully deployed?

  • #2
    Yes, just create a bean that implements ApplicationListener<ContextStartedEvent> and place your ws calling code inside the onApplicationEvent method. Refer to chapter 3.13 of the official documentation.

    Comment


    • #3
      Originally posted by Enrico Pizzi View Post
      Yes, just create a bean that implements ApplicationListener<ContextStartedEvent> and place your ws calling code inside the onApplicationEvent method. Refer to chapter 3.13 of the official documentation.
      I already tried something like this, but the problem is that the web server is not yet ready to accept web requests when the ApplicationContext is started.

      It seems like such a basic problem when dealing with seeding of data via web service calls that they should put this into the Servlet spec as a listener event.

      I get around the problem now by adding a cron job that fires every 15 seconds. Once a successful web request is made, I set a flag to abort any future cron jobs.

      Is there a way to remove a job from the task scheduler programmatically?

      Comment

      Working...
      X