Yishai
Yishai

Reputation: 91931

JBoss 6.1 not limiting the number of threads it launches with @Asynchronous

Our application is launching a series of threads via the @Asynchronous annotation on EJBs. However, JBoss (contrairy to this) is not limiting the number of threads launched. Debugging shows that it is using a default class rather than the one configured in the XML linked in the issue above. The comment on the class says:

Static singleton access to a default java.util.concurrent.ExecutorService
implementation used by clients who do not supply a
org.jboss.ejb3.async.spi.AsyncInvocation to handle asynchronous
EJB 3.1 invocations.

So the question is under what circumstances is JBoss not supplying an org.jboss.ejb3.async.spi.AsyncInvocation class and how can you ensure that this does happen?

Upvotes: 2

Views: 852

Answers (1)

Arjan Tijms
Arjan Tijms

Reputation: 38163

JBoss AS 6.1 should indeed limit the number of threads by default, but due to a bug this simply does not happen. The global setting is sadly ignored without warning.

If it doesn't concern too many beans, you can use the org.jboss.ejb3.annotation.Pool annotation:

@Pool(value = POOL_IMPLEMENTATION_STRICTMAX, maxSize = 10)
public class SomeBean {
    // ...
}

Be careful though, if I'm not mistaken this will create a pool per bean.

Upvotes: 1

Related Questions