Hazelcast 和 Payara 5 - 如果在事务上下文中使用 hazelcast,则尝试关闭实体管理器

问题描述 投票:0回答:1

我们目前正在尝试在 Payara 5.2022.x 上运行的 Jakarta EE 8 应用程序中使用 Hazelcast。 当在事务上下文中的任何方法中使用 hazelcast 来尝试访问 IMap 实例时,我们都会遇到巨大的问题。 问题似乎在于,与 Hazelcast 结合使用的 Payara 租户在每次访问 Hazelcast 地图后都会尝试拆除所有内容。 几乎 100% 的情况下都会失败,导致出现此堆栈:

 [2023-08-18T08:42:24.310+0200] [Payara 5.2022.2] [SCHWERWIEGEND] [] [com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl] [tid: _ThreadID=72 _ThreadName=hz.priceless_meitner.partition-operation.thread-9] [timeMillis: 1692340944310] [levelValue: 1000] [[
 [192.168.100.70]:4900 [development] [4.2] Failed to process: com.hazelcast.map.impl.operation.PutOperation{serviceName='hz:impl:mapService', identityHash=353117872, partitionId=105, replicaIndex=0, callId=-1914, invocationTime=1692340944309 (2023-08-18 08:42:24.309), waitTimeout=-1, callTimeout=60000, tenantControl=fish.payara.nucleus.hazelcast.PayaraHazelcastTenant@30695580, name=statefulRoomSOSChangeListenerMap} on: hz.priceless_meitner.partition-operation.thread-9
java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.
   at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:2067)
   at org.eclipse.persistence.internal.jpa.EntityManagerImpl.close(EntityManagerImpl.java:1908)
   at com.sun.enterprise.container.common.impl.EntityManagerWrapper$NonTxEMCleaner.beforePostInvoke(EntityManagerWrapper.java:1241)
   at org.glassfish.api.invocation.InvocationManagerImpl$ListComponentInvocationHandler.lambda$beforePostInvoke$2(InvocationManagerImpl.java:430)
   at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
   at org.glassfish.api.invocation.InvocationManagerImpl$ListComponentInvocationHandler.beforePostInvoke(InvocationManagerImpl.java:430)
   at org.glassfish.api.invocation.InvocationManagerImpl.postInvoke(InvocationManagerImpl.java:198)
   at fish.payara.appserver.context.ContextImpl$Context.close(ContextImpl.java:61)
   at fish.payara.appserver.context.ContextImpl$RequestContext.close(ContextImpl.java:126)
   at com.hazelcast.spi.impl.operationservice.Operation.popThreadContext(Operation.java:822)
   at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:258)
   at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:213)
   at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:175)
   at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:139)
   at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.executeRun(OperationThread.java:123)
   at com.hazelcast.internal.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:102)
]]

在许多情况下,我能够通过切换来缓解问题

javax.enterprise.concurrent.ManagedScheduledExecutorService
使用常规
Executors.newSingleThreadScheduledExecutor()
。 有时我能够用
@Transactional(TxType.NOT_SUPPORTED)
注释封闭的方法。

但这不可能是正确的方法。必须有一种方法可以在 Payara 中使用 Hazelcast,而无需避免所有交易容器魔法。

我们将不胜感激。

java hazelcast payara
1个回答
0
投票

Payara 5.2022.5 也是如此。 JCache 在请求时几乎总是失败(更准确地说,在执行 hazelcast 的 then get 操作时)。根据我的研究,它是在 Payara 5.2021.2 之后切换到 Hazelcast 4.2.* 实现时引入到 Payara 中的。

© www.soinside.com 2019 - 2024. All rights reserved.