Running a job through a Servlet

Discussion in 'Java' started by Kevin, Sep 21, 2007.

  1. Kevin

    Kevin Guest

    Hi all,

    I would like to kick of a very long running process. All classes used
    by this job are instatiated through a spring context. Our entire
    application framework (on my development teams side) is a set of
    webservices accessed by a client developed by another team. Therefore
    basically everything we do is a session. There is a very long process
    we have that we run locally that brings data in from one database,
    manipulates that data, and then places the data into a different
    database. This entire process is slow since we are in Chicago and
    both databases are in New York. What I would like to do is deploy a
    solution in our application server in New York that can run this job
    on demand. Beyond the data we take from the database we also supply
    this job with a couple simple arguments (basically two strings). I
    have been tinkering around with JMX, however this just doesn't seem to
    be panning the way I'd like. What I would like to do is create a
    simple servlet that we can feed our input of a couple string and have
    it run the job. I am in no way an expert with servelts and just have
    a couple questions before I invest time going this route (if it is
    indeed a viable route). My concern is how can I kick a task off from
    a servlet and let it continue to run when I end a browser session. As
    I said I am certainly no expert in when it comes to servlets so I am
    just curious if I could say spawn a thread to run said task and have
    this task continue to run outside of the servlets session (or context
    even). This could be a very simple thing, but just wanted to see if
    there was a good way of doing this. If there is anything you would
    like me to clear up or if I am way of base with this path please let
    me know. I appreciate any suggestions and criticism.

    Thank You,
    Kevin
     
    Kevin, Sep 21, 2007
    #1
    1. Advertising

  2. Kevin

    Filip Larsen Guest

    Kevin skrev:

    > My concern is how can I kick a task off from
    > a servlet and let it continue to run when I end a browser session.


    One way could be to let the servlet spawn a new thread to do the work
    in. Depending on how neat you want it, the servlet should probably keep
    a reference to the working thread in a suitable (global) context so you
    later can get status, result, terminate the job prematurely, and what
    else you may find need for.


    Regards,
    --
    Filip Larsen
     
    Filip Larsen, Sep 21, 2007
    #2
    1. Advertising

  3. Kevin

    Roedy Green Guest

    >One way could be to let the servlet spawn a new thread to do the work
    >in. Depending on how neat you want it, the servlet should probably keep
    >a reference to the working thread in a suitable (global) context so you
    >later can get status, result, terminate the job prematurely, and what
    >else you may find need for.

    You might be better off just to create a standalone utility. Then it
    would not be affected by the Servlet going up or down.
    The womb is not doing much for you is it?
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Sep 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    2,080
    Jack Jia
    Apr 4, 2004
  2. Replies:
    0
    Views:
    703
  3. Julien Buratto

    [Job] Symbian C++ job

    Julien Buratto, Feb 3, 2004, in forum: C++
    Replies:
    2
    Views:
    599
    Julien Buratto
    Feb 3, 2004
  4. Replies:
    2
    Views:
    450
    Roland de Ruiter
    Jul 31, 2006
  5. Replies:
    4
    Views:
    838
Loading...

Share This Page