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.The service models need to be synchronous,
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 |
