The easiest way to perform asynchronous operations in Java web applications

I have Java servlet based web applications. I would like to implement some operations in asynchronous mode, for example, to write to the log.

I would like to avoid the overhead of JMS and do something simple.

Thread management alone does not seem like such a good idea in a server environment; you probably need to use a server thread pool, etc. What is the best alternative to simple asynchronous operation?

Edit:

Just for clarification, since many of them suggest using log4j or another logging library, writing to the operation log here is more of an example. I am wondering how to perform asynchronously any operation that should not be performed sequentially. The idea is to immediately respond to the user and continue processing expensive work in another thread.

As for the problem with the journal, we have an audit journal, which we implemented to write a large amount of data to the database and is used by the user during audit operations and in the help desk. Writing a lot of information in a database can be very expensive. We use log4j for syslog, and since appender is a file application, we have no performance issues in our syslog.

+5
4

, . , , .

Queue ( ConcurrentLinkedQueue) ( , , ). . notify() .

: ( ).

(, Timer, Future,...), , .

+1

, , , Log4j .

0

, , .

, http://mina.apache.org/ apache , , .

0

, , , . , , ( , ).

, , - , , JMS.

, SLF4J, Log4J .

, , .

0

All Articles