Question

I am currently implementing a custom task inside wso2 esb, which checks some processes on the server and starts them if processes are not up. However i also need to stop those processes if wso2 carbon instance on the server stops. Apache synapse task interface only has execute method. Is there an interface in the apache synapse or wso2 carbon where it provides methods like start and stop or is it possible to convert a synapse scheduler task into an osgi bundle?

Thanks

Was it helpful?

Solution

Solved

Hope this info will be useful for others. Second part of my question "is it possible to convert a synapse scheduler task into an osgi bundle" is the real question and answer is yes. In wso2 you can write your own bundle and drop it to {carbon_server_path}/repository/component/dropins and when server start it installs the bundle. So here is some code snippets showing my implementation:

Task implementation

    package com.fga.test.task;

    import org.apache.synapse.task.Task;


    public class ProcessChecker implements Task  {



    @Override
    public void execute() {

          //Check for processes and start them
    }
}

Bundle Activator

    package com.ardic.arcsp.cluster.task;

    import org.osgi.framework.BundleActivator;
    import org.osgi.framework.BundleContext;

    public class Activator implements BundleActivator {


   /**
    * Initializes process list from configuration file
    */
    @Override
    public void start(BundleContext context) throws Exception {
          //Do some initialization


    }

     /**
      * Stops all processes
     */
    @Override
    public void stop(BundleContext context) throws Exception {
           //Get process list from config file and stop them
    }

Activator start and stop call method will be called at server start and stop event respectively.

Note: Here maven bundle plugin is used for creating bundle and my work environment was WSO2 esb version 4.0.2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top