On Wed, Jun 17, 2009 at 11:15, <[email protected]> wrote: > > Josef, > > thanks for your answer, it seems you had a hard debugging session ;) > I'm actually evaluating to go for a new thread. > > To be honest, I would prefer by far the simplier solution to execute my code > inside the ws thread. But It seems that it is something impossible to do with > Axis2. > > Does someone knows why the Axis Phases framework has no phase after the > response is sent? Is it an explicit design choice?
I would say that this is by design. Indeed, the appropriate pattern in this case is to execute the code in a separate thread. It also makes sure that all the resources allocated to the request are freed when the response is sent back. > Grazie, > Vittorio > > > > > --- Mar 16/6/09, Stadelmann Josef <[email protected]> ha > scritto: > >> Da: Stadelmann Josef <[email protected]> >> Oggetto: AW: How to execute user code after response sent >> A: [email protected] >> Data: Martedì 16 giugno 2009, 18:27 >> 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:[email protected]] >> >> Gesendet: Freitag, 12. Juni 2009 12:14 >> An: [email protected] >> 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 >> >> >> >> >> > > > > > >
