Java – hazelcast thread prevents tomee from stopping

context

We want to use hazelcast as our jcache implementation in tomee Because we don't need crazy performance, we want to run hazelcast node as part of our application at present

We use hazelcast 3.7 and tomee 7.0 one

problem

When tomee is stopped, it complains about the warning - the web application [application_name] appears to have started a thread named [somename] but failed to block it This is likely to cause a memory leak Many times, the VM will not stop normally, but continue to run

The obvious solution is to terminate the process immediately when it appears idle There is no doubt that this is driving our developers and developers crazy

Separate hazelcast nodes

In order to eliminate the possibility of problems caused by running hazelcast node inside tomee, I tried to start a separate hazelcast node and change our application to connect to the node only using hazelcast client Behavior remains unchanged As far as I know, from several network searches, hazelcast client also started several threads to communicate with server nodes

No duplicate hazelcast prevents the JVM from terminating

This problem is not the same as hazelcast precautions the JVM from terminating, because we completely rely on hazelcasts jcache implementation We do not directly access the hazelcast instance, so we cannot call shutdownall()

test case

I created a small test case on GitHub to reproduce the problem

problem

>Can we use hazelcast as a jcache backend in Java EE applications? > What do we need to do to stop the application properly? > Can we also run the hazelcast node as part of our application? If not: why is this a bad idea?

Solution

Hazelcast uses its own threads and they are not always daemons, you can ensure that https://issues.apache.org/jira/browse/TOMEE-1723 Such producers close hazelcast instances (clients or nodes)

Hazelcast is probably the cleanest before it fixes the life cycle of its instance through CDI extension

Note: this can also use the tomee internal server API to start the instance in advance, but it is not required in most cases

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>