Implement concurrency in a Java EE web application

We are creating a web application where we need to have concurrency for several business cases. This application will be deployed in the tomcat container. I know that creating custom threads in a web container is a bad idea, and I'm trying to explore the options that I have.

  • Use my multithreaded library as a JCA component. We are not inclined to use this approach because of the learning curve that may be involved.
  • I know that there is a WorkManager API, but I think this is not implemented by tomcat, so this parameter does not work.
  • I did some research and found that the CommonJ library is recommended for Tomcat. Has anyone used it?
  • In addition, I see that there is a ManagedExecutorService, but I'm not sure how to use it and is different from the WorkManager API (and the commonJ library)?

Any help on this is appreciated. By the way, using JMS is out of the question due to the deployment environment. I am inclined to points 3 and 4, but I have little knowledge about this. Can anyone lead pls.

+5
source share
4 answers

Since you are using Tomcat, don't worry about it and do whatever you want. The Java EE servlet section does not mention threads, etc. This is mainly in the EJB section.

Tomcat itself has nothing to do with worrying about flow control; it's a pretty non-invasive container.

ServletContextListener, , , , .

-

- , . Tomcat HTTP- . Tomcat HTTP , , . Tomcat , , - .

, HTTP . Java EE , . , , Java EE API, , , Tomcat.

Tomcat. Tomcat - . .

( JDK ) , , , . .

+4

. , , . , Servlet, , , - .

Java SE . Servlet . , . ( ).

- OpenEJB , @Asynchronous annotation.

- , Tomcat, - . -, Tomcat. , () , Tomcat , ( ). TomEE, GlassFish, Resin, JBoss AS, Geronimo ..

+1

Servlet -Java EE HTTP- - - - Singleton, , / . - - Tomcat - .

Also, you need to keep in mind some considerations for multi-threaded processing in your code. For example, since servlets are single and many threads spawned for this class, it is a bad idea to have instance attributes in these components.

0
source

I have used CommonJ many times and it works very well. It can be initialized and destroyed from ServletContextListener.

0
source

All Articles