What is the proper way to handle EntityManager instances relative to threading

Solution In Progress - Updated -

Issue

We are currently load testing our application infrastructure on top of JBoss FUSE 6.1.0 and are seeing issues relative to OpenJPA and multithreaded access. The error being seen is:

Multiple concurrent threads attempted to access a single broker. By default brokers are not thread safe; if you require and/or intend a broker to be accessed by more than one thread, set the openjpa.Multithreaded property to true to override the default behavior.

While it sounds like there is an OpenJPA multithreaded property, it sounds like that is not something we want to be using. Our current Blueprint bean definition is:

<bean 
    id="deviceTokenStorage" 
    class="com.redhat.support.oauth.service.impl.jpa.JPADeviceAccessTokenStorageImpl">

    <jpa:context property="entityManager" unitname="deviceRegistrationPersistenceUnit" />
    <tx:transaction method="is*" value="Supports" />
    <tx:transaction method="*" value="Mandatory" />
</bean>

meaning we have singleton scope for the bean. We are also going to try "prototype" scope as well to see if that changes behavior. Even if that works, it begs the question about what is the proper or best way to handle these issues?

Environment

  • Red Hat JBoss Fuse 6.1.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.