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.