You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Vittorio Rigamonti <ri...@yahoo.it> on 2009/06/12 12:13:49 UTC

How to execute user code after response sent

Ciao All,

I'm developing an application with tomcat-spring-axis2 frameworks. Currently I'm working on a ws which provides synchronous service.
 
I need help on this point (I looked at the docs but it seems I want to do something unusual):

does axis2  (or spring) provide a way to execute some user code after the response has been sent by the service to the client?

Grazie,
Vittorio



      

AW: How to execute user code after response sent

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Vittorio

I don’t know spring, but read about it.

And I went with the debugger through axis2 for weeks.

However! Your ws-request comes to your ws-method() on a given thread; 

that thread executes all of your ws-method() code and all what happens before and after; 

when the method has executed, the thread still exists and passes back through axis2-engine, through modules, phases etc. (axis2 a message processing engine) your response package. 

When the thread finishes all this work, when it has put the response to the wire, it has nothing to do any longer and for performance reason it is not destroyed but returns to a thread-pool - waiting to be engaged / invoked for its next job.

When a new request comes in, that thread might be located in the pool as waiting for work, then work is given to it and it can start working again, i.e. work up your next ws-method() call.



Threads can be created, are busy, are waiting for something, have to be synchronized among other threads, they can be destroyed. Threads have state.


What hinders your working axis2-thread to create a new thread?

Nothing!

So let your method create a thread, let's name it helper-2, agree on some locking, some event, some semaphore or any other sync-flag threads use to correspond, up on which - when set - helper-2 shall (i.e. optional after a delay of 5 ms), start working and do its job. 

The question is; when can helper-2 start earliest and how do we signal that.

Helper-2 then calls a method which can call other methods, create objects, build a system from objects, executed by helper-2, and then when the method is all finished - the thread returns and is destroyed or it is given back to the originating pool, where it waits for another job.



Axis2 / tomcat / jvm / -- we are talking about complex multi-threaded-systems --- so any such thing can be done ---


Just consider, that in real operation, many users-client can send messages to the endpoint and axis2 engine has to start working, speak has to get a free thread from a pool of threads or create a new one, and have this arriving requests processed. 


How many threads is axis2 concurrently supporting?


I strongly suggest you to go for threading in Java, and learn from a simple example how to make one thread call another and let it do some work. Then have your first thread be informed when work is done and check that work. The model can be that of a manger and a work.
 

And if you master that, then you are ready to do what you want, given you master threads and thread-synchronization.


I hope this helps as a starting point.

Josef Stadelmann
@axa-winterthur.ch



-----Ursprüngliche Nachricht-----
Von: Vittorio Rigamonti [mailto:rigazilla@yahoo.it] 
Gesendet: Freitag, 12. Juni 2009 12:14
An: axis-user@ws.apache.org
Betreff: How to execute user code after response sent


Ciao All,

I'm developing an application with tomcat-spring-axis2 frameworks. Currently I'm working on a ws which provides synchronous service.
 
I need help on this point (I looked at the docs but it seems I want to do something unusual):

does axis2  (or spring) provide a way to execute some user code after the response has been sent by the service to the client?

Grazie,
Vittorio