The test fails because not all MDB invocations pass successfully. The expected number of calls is 1000 and on my local machine I see around 950 invocations. So where do these calls get lost? If you analyze the output of the test you see exceptions like this:

javax.resource.spi.UnavailableException: Only 10 instances can be created at org.apache.openejb.core.mdb.MdbInstanceFactory.createInstance(MdbInstanceFactory.java:117) at org.apache.openejb.core.mdb.EndpointHandler.<init>(EndpointHandler.java:78) at org.apache.openejb.core.mdb.EndpointFactory.createEndpoint(EndpointFactory.java:78) at foo.bar.TestResourceAdapter$TestWork.run(TestResourceAdapter.java:110) at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:366) at org.apache.geronimo.connector.work.pool.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Apparently someone tries to invoke the MDB even though the maximum number of beans is in use. Obviously the default maximum number of beans is 10.

If you look at the top of the output you will see that the default thread pool size for a resource adapter is 30:

Okt 04, 2014 10:30:35 PM org.apache.openejb.assembler.classic.Assembler createResource INFORMATION: Thread pool size for 'test.rarRA' is (30)

And the Work objects are executed by this thread pool as you can see from the output:

foo.bar.RATest STANDARD_OUT TestWork.run on thread Thread[test.rarRA-worker- - 6,5,main]

So here we have the conflict: 30 threads are firing invocations concurrently at only 10 bean instances. And according to the specification the application server is allowed to refuse the call with an UnavailableException . This default configuration can lead to errors if the resource adapter does not handle these exception by retrying the invocation.

At first thought this does not make any sense and makes you probably think why are these two pool sizes not identical? But it makes sense if you have multiple MDBs that are activated for the same resource adapter: If you have three MDBs that register for the same resource adapter the math works again as long as the calls are distributed equally across the MDBs.