Announcement Announcement Module
Collapse
No announcement yet.
wanna control thread using webservice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • wanna control thread using webservice

    I have a spring application, where i am reading a database constantly and putting filtered data in some other database. App is ready and now i want some other application (may be written in java, php or .net) to manage the execution of this application (I am new in web service), I am trying to integrate axis2 in spring app.

    I have one business class extending the Thread class (Singleton):

    Code:
    public class BusinessObject extends Thread {
    
      // ... some code here
    
      private static BusinessObject obj;
      private volatile boolean goAhead = false;
    
      private BusinessObject(){
      }
    
      public static BusinessObject getInstance(){
        if(obj == null){
          obj = new BusinessObject();
        }
    
        return obj;
      }
    
      public void run(){
    
        while(goAhead){
    
          // ... some code here to read the database and update another database.
    
        }
    
      }
    
      public void stop(){
    
        goAhead = false;
    
      }
    
      public boolean status(){
        return goAhead;
      }
    
      // ... some code here
    
      }
    }

    I have one service class extending ServletEndpointSupport

    Code:
    public class ProcessManagerService extends ServletEndpointSupport {
    
      // ... some code here
    
      BusinessObject bo = BusinessObject.getInstance();
    
      public String start(){
    
        if(!bo.status()){
    
          bo.start();
    
        }
    
        return "RUNNING";
      }
    
      public String stop(){
    
        if(bo.status()){
    
          bo.stop();
    
        }
    
        return "NOT-RUNNING";
      }
    
      public String status(){
    
        return ( ( bo.status )?"RUNNING":"NOT-RUNNING");
    
      }
    
      // ... some code here
    }
    I exposed 3 methods:

    start(); // to start the process in thread (i just want a single thread)
    stop(); // to stop the thread
    status(); // check the current status of that thread

    i also configured in services.xml that this service will have shared access for all clients

    Code:
    <parameter name="scope">Application</parameter>
    but seems like still something wrong with the design/application.. it starting the thread but stop and status method not working.. can someone please advise how can i achieve my goal.

    Regards
    Mubeen

  • #2
    sounds like you should, instead, write the app as a stand alone batch process and interact with it via socket, JMS, files, or other asynchronous mechanism.

    Comment

    Working...
    X