George Baxter wrote:
Hi all,

We're hoping to use Tuscany for our stateless services.  These services, by and 
large, can be (and should be) totally stateless and thus, in the interest of 
lower GC issues, singletons.  Great, we @Scope them as Composites.

However, if we want to have an asynchronous 'conversation' with these... well.. we haven't figured out how to do it.
Issues:

1. The callback functionality is injected into the destination component object rather than maintained by a proxy. If this object is a singleton-ish entity.. well, not thread safe.
>
If the destination component is a singleton (composite scoped), it shouldn't
use injection for the callback proxy.  Instead, it should obtain the current
RequestContext object and get the callback proxy from that.  Here's an example
of the code that you need when using this approach:

@Context
ComponentContext context;

public void someMethod() {      
    MyCallback myCallback = context.getRequestContext().getCallback();
    ....
    myCallback.receiveResult(theResult);
}

2.  When the callback is actually made, the originating caller (that might be 
scoped as 'Conversation') can't be located and a new instance is created.  This 
may be because the singleton's callback is being corrupted (overwritten).. thus 
just another variant of issue 1.

I'm not sure about this.  Please can you try making the change suggested above
and see if that improves things.
So is it possible to scope a component as a 'Composite' and yet enable 
'Stateless' or 'Conversation' scoped components interact with them in any 
asynchronous way?

Yes, it should be possible if you use the approach described above.

  Simon

Thanks,

George


Reply via email to