Servlets should not start threads due to problems that might occur during clustering ... what problems?

I know that we should not start streams in the servlet, so that streams should be managed by the container. If the container is informed of completion, if there are threads that it does not know about hanging around, it will not be completed. I will take care of this, making him a stream of demon ...

But apart from the situation described above, β€œfailed to shut down”, what other reason may not be possible so that the servlet does not start threads. I have seen some mention that if the environment is clustered, this will cause a problem. But no actual passage from what could happen would be bad.

EDIT: This is currently being done in the servlet, and I am having problems convincing the author of this code that this is not a good idea. The argument that you need to understand the complexity is not going to fly ... I am looking for a specific specific case when something bad can happen without intending to

In my situation: the servlet in question starts n threads, and this happens in every vm on the cluster by design. No transaction requirement required

+3
source share
2 answers

From the official frequently asked questions :

Why is creation and flow control prohibited?

EJB EJB . bean . -, , , . bean . , , bean.

, , "" , , , , . .

, . .. , , .

, , .

, . . , , , (, ) UserTransaction, . , , . , , .

, - ServletContextListener , , node. , JVM , .

+2

. , , / , , ? - ? ? ? , .... JMS, Tomcat, ActiveMQ , . YMMV

+1

Source: https://habr.com/ru/post/1757723/


All Articles