What if the service interface’s method returns something?� How can it be asynchronous?� I agree that the Executor interface could be used as a service itself, but to use that idea as a service model doesn’t work IMHO.� My suggestion would be to expose the Executor (or actually ExecutorService in JDK 5.0) interface as a service in your registry (as you’ve already done it seems) and let other services use it.� A service model itself cannot be asynchronous, as it is a mechanism for performing a method call (which is inherently synchronous) on an object.� Even when you call the Executor.execute() method, it’s a synchronous call.� The method does what it’s supposed to do (adds the Runnable to a queue or something) and returns.�

 

-----Original Message-----
From: Pablo Lalloni [mailto:[EMAIL PROTECTED]
Sent: Monday, October 25, 2004 9:23 AM
To: hivemind-dev
Cc: 'Marcus Brito'
Subject: RE: Pooled Service Model enhancements

 

El lun, 25-10-2004 a las 09:25, James Carman escribi�:

The service models need to be synchronous, 

Not necessarily... we've made extensive use of ThreadPoolExecutor (as a service) for firing events that need to be processed asynchronously with great success so far. Of course, event-listeners are other services.
We used the Executor interface from concurrent as a service interface and defined a set of executors which can be plugged in services that represent events to be fired, then when some other service fires an event, it's event-service use the executor provided to notify the registered listeners.
We also provide the executors with a ThreadFactory (another SP) which surround the run() method with appropriate calls to fireThreadCleanup(), hence it all works great!
We have asynchronous processing, and with a lot of tuning possible through PooledExecutor, ThreadedExecutor and QueuedExecutor (from oswego.concurrent) params.

In fact, we're looking forward to implement schedulers to use as a HiveMind service probably wrapping functionality from concurrent as well.

Regards.

--

Pablo I. Lalloni 
Tel�fono +54 (11) 4347-3177 
Proyecto Pampa
Direcci�n Inform�tica Tributaria
AFIP
 

Reply via email to