Я использую игровую среду и JPA. Несколько сообщений передаются актерам Akka для асинхронной обработки. Внутри асинхронного процесса мне нужно подключить мою базу данных через JPA.
public class OrderCreation extends UntypedActor {
private EntityManagerFactory emFact = null;
private ActorSelection provisioner;
@Transactional(readOnly = false)
@Override
public void onReceive(Object order) throws Exception {
//HERE I need to do JPA related transactions
}
@Override
public void postStop() throws Exception {
}
@Override
public void preStart() throws Exception {
provisioner =getContext().actorSelection("/user/OrderProvisioner");
emFact = Persistence.createEntityManagerFactory("test-data-play");
}
}
я получил эту ошибку
[akka://application/user/OrderCreation] No EntityManager bound to this thread. Try wrapping this call in JPA.withTransaction, or ensure that the HTTP context is setup on this thread.
java.lang.RuntimeException: No EntityManager bound to this thread. Try wrapping this call in JPA.withTransaction, or ensure that the HTTP context is setup on this thread.
at play.db.jpa.JPA.em(JPA.java:58)
У кого-нибудь есть идея подключить JPA через Akka?