multiThreadTranslate is a multi-threaded REST client that showcases parallel HTTP requests for text translation. This project is split into two services:
- mockTranslate: Handles transliteration between English (en) and Russian (ru).
- main: The primary service that interacts with
mockTranslateto demonstrate the translation process.
The system uses a configurable thread pool (default is 5 threads) to send translation requests in parallel, optimizing performance for intensive I/O operations such as HTTP requests in a Java Spring Boot environment.
- Multi-threaded translation requests for enhanced performance.
- Parallel processing of translation tasks.
- In-memory H2 database to log:
- Timestamp of the translation request.
- Input parameters (source text, source and target languages).
- Client's IP address.
curl -L 'http://localhost:8080/translate' \
-H 'Content-Type: application/json' \
-d '{
"text": "Once the application is running, you can use any HTTP client",
"from": "en",
"to": "ru"
}'Output:
[
"ОНcЭ",
"ТХЭ",
"АППЛИcАТИОН",
"ИС",
"РУННИНГ",
"ЁУ",
"cАН",
"УСЭ",
"АНЫ",
"ХТТП",
"cЛИЭНТ"
]curl -L 'http://localhost:8080/translate'Output:
[
{
"id": 1,
"text": "Once the application is running, you can use any HTTP client",
"from": "en",
"to": "ru",
"createdDate": "2024-05-05T12:50:45.260221Z",
"ip": "172.31.0.1"
}
]These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Git
- JDK 17 or later
- Gradle
- Docker
git clone https://github.com/Azark1n/multiThreadTranslate.git
cd multiThreadTranslate
./gradlew bootJar
docker compose up -d