adam bien's blog

Project connectorZ--Lean JCA 1.6 Connector Implementations 📎

connectorZ project is an example connector implementation under Apache 2.0 license.

The initial project (work-manager) implementation uses JCA WorkManager to execute Runnable implementations asynchronously:


@Stateless
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class ThreadsResource {

    @Resource(name="jca/workmanager")
    WorkExecutorFactory executorFactory;
    
    public String threads(){
        try(WorkExecutor executor = executorFactory.newExecutor();){
        Runnable runnable = new Runnable(){
            @Override
            public void run() {
            //some work to do
            }
        };
        executor.execute(runnable);
  }
                        

The main benefit over the EJB 3.1 @Asynchronous annotation is better management and monitoring. JCA's connection pooling is configurable by application server, so throttling and monitoring comes for free.

[The connectorZ project was initiated by factoring out examples from the book "Real World Java EE Patterns--Rethinking Best Practices" book (Second Iteration), page 303 in, chapter "Generic (File) JCA"]

See you at Java EE Workhops at MUC Airport (October 22nd-24th)!