
You might required to execute asynchronous processes inside the Axis2 context. One way of doing it is implement your own thread model and execute the relevant processes inside a thread.
But Axis2 got its own thread model with a thread pool that will make the life easy of the Axis2 developers. You can identify how simple it is by following the instructions given below.
Get reference to the Axis2 thread pool :
ConfigurationContext confCon = new ConfigurationContext(axisConfig);Create a ConfigurationContext using the active AxisConfiguration object. Axis2 ThreadFactory can create by using the Configuration context.
ThreadFactory threadFactory = confCon.getThreadPool();
Create your own thread :
Create your own thread by using Thread class or Runnable interface and implement the abstract method run by putting the asynchronous process.
class WorkerThread implements Runnable{
public void run() {
//async process
}
}Execute the Axis2 thread :WorkerThread worker = new WorkerThread(//params);Execute the worker thread by passing the worker thread object to the execute method of the Axis2 ThreadFactory.
threadFactory.execute(worker);

2 comments:
Is Axis running in Tomcat?
Because also Tomcat has its own Thread Pool (see http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/tomcat/util/threads/ThreadPool.html).
Do you know if this could be interfere with the ThreadPool of Axis2?
If yes, you should manage also this.
Is Axis running in Tomcat?
>>of course Axis/Axis2 runs on tomcat.
Yes when it come to Tomcat , Axis2 does not going to worry about creating threads. When a request hits AxisServlet it has a thread. So we just use that. Axis2 thread pool is more useful when you run Axis2 as standalone server.
Thank you!
Deepal
Post a Comment