Results 1 to 3 of 3

Thread: Invoking a web service when web server starts

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Columbus, OH
    Posts
    65

    Default 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. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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.

  3. #3
    Join Date
    Aug 2004
    Location
    Columbus, OH
    Posts
    65

    Default

    Quote 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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •