Ignacio, Thanks for the quick reply.
I am currently experimenting with writing "SIP enabled" SCA components. SIP is an asynchronous request/response, session-based protocol, similar to HTTP. Tuscany is deployed within our SIP application server. Our SIP app server receives each incoming SIP request on a separate thread and sends each SIP response on a separate thread (obviously the threads are taken from a thread pool). Therefore the thread that processes the SIP request is not the same that sends the corresponding SIP response. The SIP request and SIP response belong to the same SIP session. The idea is to have a Connect component that has bi-directional interfaces (i.e. a service and callback interfaces). Here is the scenario I have been trying to implement: 1) The application calls the dial() method on the Dial component. 2) The dial() method creates and sends a SIP request to the SIP endpoint. The SIP request is sent asynchronously (i.e. the dial() method does not block until the SIP response is received). 3) The Connect component implements a listener that gets invoked when the SIP response is received by the SIP application server. The listener eventually receives the SIP response and then invokes a method called success() on the callback interface. The issue I am facing here is that the listener gets invoked from a different thread than the one used to send the SIP request. I realize that the threading model used here is a little different than the one you described below. However I was wondering if you would have any idea how this scenario could be handled nicely by Tuscany/SCA. I was also wondering whether you thought the conversation feature that you are planning to implement in Tuscany would be suitable for the scenario described above. Thanks for your input, Martin. -----Original Message----- From: Ignacio Silva-Lepe [mailto:[EMAIL PROTECTED] Sent: Thursday, November 09, 2006 12:45 PM To: tuscany-dev@ws.apache.org Subject: Re: SCA component invoking a callback from a separate thread Without looking at your whole component assembly or application, it's not clear to me why you would want to create your own thread. I assume your ComponentService.class includes a @Callback annotation to indicate what its callback interface is. This is sufficient to tell Tuscany that your Component.class methods are to be invoked on a separate thread, on which the callback invocation is also performed. Tuscany uses this thread to key a work context on which it caches the stack of from addresses that you are missing at the moment. If you look at the simplecallback sample you'll notice that MyServiceImpl invokes its callback method without having to deal with thread manipulation. On 11/9/06, Martin Leclerc <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I am trying to write an SCA component that invokes a callback > asynchronously (see code at the bottom of this message). In order to > simulate an asynchronous notification, a new thread is created and the > callback is invoked from within that thread. > > > > When I execute the application it throws the following exception: > > > > Exception in thread "Thread-0" java.lang.AssertionError: Missing stack > of from addresses > > at > org.apache.tuscany.core.wire.jdk.JDKCallbackInvocationHandler.invoke(JDK > CallbackInvocationHandler.java:61) > > at $Proxy17.done(Unknown Source) > > at test.Component2$1.run(Component2.java:32) > > at java.lang.Thread.run(Unknown Source) > > > > I suspect that the context required for the callback to work is not > available from the new thread. > > > > My question is: is there a way for my component to invoke a callback > from a different thread? If so, how can it be done? > > > > Thanks for your help, > > > > <sample code> > > > > @Service(ComponentService.class) > > public class Component implements ComponentService > > { > > private ComponentServiceCallback m_Callback; > > > > public Component() > > { > > } > > > > @Callback > > public void setCallback(ComponentServiceCallback a_Callback) > > { > > m_Callback = a_Callback; > > } > > > > public void run() > > { > > Runnable exec = new Runnable() > > { > > public void run() > > { > > m_Callback.done(); > > } > > }; > > new Thread(exec).start(); > > } > > } > > > > </sample code> > > > > ------------------------------------- > > Martin Leclerc > > Technical Architect > > Ubiquity Software > www.ubiquitysoftware.com <BLOCKED::http://www.ubiquitysoftware.com> > > Phone: (613) 271-2027 > > Email: [EMAIL PROTECTED] > <BLOCKED::mailto:[EMAIL PROTECTED]> > > MSN: [EMAIL PROTECTED] > > > > > > Information contained in this e-mail and any attachments are intended for > the use of the addressee only, and may contain confidential information of > Ubiquity Software Corporation. All unauthorized use, disclosure or > distribution is strictly prohibited. If you are not the addressee, please > notify the sender immediately and destroy all copies of this email. Unless > otherwise expressly agreed in writing signed by an officer of Ubiquity > Software Corporation, nothing in this communication shall be deemed to be > legally binding. Thank you. > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]