Create a web service using your preferred programming language and framework (e.g., Python with Flask).
Implement two endpoints:
/orders
(POST): Accepts JSON payload representing a product order and publishes it to the Kafka topic "product_orders"./orders
(GET): Retrieves all product orders from the PostgreSQL database and returns them as JSON.
Implement a DB sink connector which reads "product_orders" topic and writes the data to a table called orders
in Postgres DB.
Write a Kafka consumer which consumes from "product_orders" and writes to a respective city topic. For ex, in the below order payload:
{
"order_id": 12345,
"customer": {
"name": "John Doe",
"email": "[email protected]",
"address": {
"street": "123 Main St",
"city": "Chennai",
"state": "Tamil Nadu",
"postal_code": "600004"
}
},
"product_name": "Widget",
"quantity": 2,
"order_date": "2023-06-09",
"priority": "medium"
}
will write the message to a topic called Chennai
.
Finally, write a consumer which will send an email to customer if the priority
field is high
. Just implementing a dummy send_email function in consumer is enough.
- use docker compose for the entire setup. Kubernetes cluster is also OK.
- Add a README for this exercise explaining what it does and how to run everything.