A Spring Boot application that processes P2P transactions asynchronously. It integrates with a Risk API to evaluate each transaction and publishes approved/rejected events to Apache Kafka.
- Java 21
- Spring Boot 4.0.6
- Apache Kafka
- MockServer (for local Risk API simulation)
- A transaction is submitted via
POST /transactions/p2p. - The service calls the Risk API to check if the transaction is allowed.
- The result is published to a Kafka topic (
transactions). - If the Risk API is unavailable, the transaction is sent to a dead-letter topic (
transaction-dead-letter). - The status of a transaction can be queried via
GET /transactions/{transactionId}/status.
| Method | Endpoint | Description |
|---|---|---|
| POST | /transactions/p2p |
Submit a new P2P transaction |
| GET | /transactions/{transactionId}/status |
Get the status of a transaction |
{
"transactionId": "abc123",
"amount": 100.0,
"sender": "user1",
"receiver": "user2"
}{
"transactionId": "abc123",
"status": "APPROVED",
"reason": null
}- Java 21
- Docker & Docker Compose
docker-compose up -dThis starts:
| Service | Description | Port |
|---|---|---|
mockServer |
Simulates the Risk API | 1080 |
zookeeper |
Kafka coordination service | 2181 |
kafka |
Kafka broker | 9092 |
./gradlew bootRunThe application will be available at http://localhost:8080.
docker-compose downKey properties in src/main/resources/application.properties:
| Property | Default | Description |
|---|---|---|
risk.api.url |
http://localhost:1080/risk |
Risk API endpoint |
kafka.bootstrap-servers |
localhost:9092 |
Kafka broker address |
kafka.topic.transactions |
transactions |
Main Kafka topic |
kafka.topic.dead-letter |
transaction-dead-letter |
Dead-letter Kafka topic |
kafka.enabled |
true |
Enable/disable Kafka |
./gradlew testGET /risk?transactionId=1
Response:
{
"result": "allowed"
}
or
{
"result": "notAllowed"
}http://localhost:1080/mockserver/dashboard