Problem
Currently, AuditService.log() and logCaseAction() call repository.save(log) synchronously.
This blocks the request thread until the database write completes, which slows down case operations under heavy load.
Proposed Improvement
- Replace the existing synchronous methods with asynchronous ones by annotating them with
@Async.
- Keep the same method names (
log, logCaseAction) to avoid duplication and confusion.
- Ensure
@EnableAsync is already active in the main application class (confirmed).
- Controller calls remain unchanged, but logging will now run in a background thread.
Impact
- Performance: Faster API responses since logging is offloaded.
- Scalability: Handles higher logging volume without blocking request threads.
- Clean design: No duplicate methods; existing service methods simply become async.
Steps to Implement
- Add
@Async annotation to AuditService.log() and logCaseAction().
- Verify that
@EnableAsync is present in the main application class.
- Test by firing multiple concurrent requests and confirming logs are persisted correctly.
Problem
Currently,
AuditService.log()andlogCaseAction()callrepository.save(log)synchronously.This blocks the request thread until the database write completes, which slows down case operations under heavy load.
Proposed Improvement
@Async.log,logCaseAction) to avoid duplication and confusion.@EnableAsyncis already active in the main application class (confirmed).Impact
Steps to Implement
@Asyncannotation toAuditService.log()andlogCaseAction().@EnableAsyncis present in the main application class.