https://github.com/znsio/specmatic-async-order-api-kotlin
Order API accepts request for an order which is created asynchronously.
https://github.com/znsio/specmatic-async-order-api-kotlin
request-reply
Last synced: 6 months ago
JSON representation
Order API accepts request for an order which is created asynchronously.
- Host: GitHub
- URL: https://github.com/znsio/specmatic-async-order-api-kotlin
- Owner: znsio
- License: mit
- Created: 2025-03-16T05:09:52.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-04-17T12:19:31.000Z (6 months ago)
- Last Synced: 2025-04-18T02:52:29.979Z (6 months ago)
- Topics: request-reply
- Language: Kotlin
- Homepage:
- Size: 6.78 MB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# async-order-api
Order API accepts request for an order which is created asynchronously.
1. Upon receiving request to create Order, it adds entry into SQL DB with status as `ACCEPTED`, sends a message on Kafka for further processing and responds with a `202`
2. Eventually when it hears back on a separate Kafka topic about the status of the Order it updates the status of that Order in the SQL DB
3. The service also exposes a `GET` endpoint so that API consumers can view the status of the Order## Specmatic Contract Test Setup
1. We use OpenAPI spec to contract test on the HTTP interface which results in the application posting to a Kafka Broker
2. And Specmatic Kafka Mock uses AsyncAPI spec to spin up a Mock Kafka Broker to received, validate and respond with appropriate messages
a. We are leveraging `request-reply` pattern in AsyncAPI here## How to run contract tests manually?
1. Set up the specmatic kafka mock:
```shell
./setup-specmatic-kafka-mock.sh
```
2. Run the application:
```shell
./gradlew bootRun
```3. Run the contract test:
```shell
./runContractTest.sh
```4. Stop the application.
5. Clean up the specmatic kafka mock once test run is complete:
```shell
./cleanup-specmatic-kafka-mock.sh
```