Technical stack used:
- Java
- Cassandra
- Spring-boot
- Kafka
Cassandra should be installed in the machine, listed with the below configuration.
CREATE KEYSPACE myretailapp
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
CREATE TABLE myretailapp.price (
productid text,
price text,
currency text,
PRIMARY KEY (productid)
);
insert into myretailapp.price(productid, price, currency) values ('13860428', '50', 'USD');
cqlsh:myretailapp> select * from myretailapp.price;
productid | currency | price
-----------+----------+-------
13860428 | USD | 50
(1 rows)
cqlsh:myretailapp> select * from myretailapp.price;
- Use of Spring cloud, Eureka server will provide load balancing which decreases the latency and improves fault-tolerance.
- To implement this Start a Eureka Server instance.
- Register multiple instances of the redsky.
- Enable Eureka client discovery in client application (MyRetailApp), based on the availability zone client application will contact one of the instances of redsky application.
- Use Kafka for storing updates for price. So that the downstream application will be notified. This encourages the event driven architecture.
Enhance the application with the event based architecture
Ex: Once an update is made on the product price, the series of events should be triggered and store the messages to KAFKA. And the downstream applications such as inventory or stock services will get this update by listening to kafka. With this design, microservices will be better communicated independently in a decouple way.
Post request on updating the price. Updating the price to 53
Post request Successfully updated the price to 53.
Price update is sent to Kafka.