Bidding Server is a custom, high performance, auction server for this online car auction company's web based auctions. Biding Server manages all the aspect of the whole auction process, from creating an auction to announcing a winner.
The server allows following capabilities to their web-based auction clients:
- Only admin must be able to create auction
- If there already exists a running auction for the given item then auction will not be created
- If there already exists a running auction for the given item then auction will not be created
- user can bid on a running auction
- Only logged in users are allowed to place bid
- Accepted or rejected all user bids must be recorded
- User must not be able to bid on an item which has no running auction or the auction is expired
- Only logged in users are allowed to place bid
- user must be able to get the list of running auction
- If user gave an invalid auction status system must return null response
- If user gave an invalid auction status system must return null response
- Bid Accept Scenarios
- If there exists no bid against the item and bid amount greater than or equal to base price
- If there exists a bid against the item and upcoming bid must be greater than or equal to sum of highest bid and step rate
- If there exists no bid against the item and bid amount greater than or equal to base price
- Bid Rejected Scenarios
- If there exists no bid against the item and bid amount is less than base price
- If there exists a bid against the item and upcoming bid is less than the sum of highest bid and step rate
- If there exists no bid against the item and bid amount is less than base price
- Auction not found scenarios
- If auction is expired
- If auction is null
- If item does not have running auction
- If auction is expired
- As soon as the auction is over winner receives email
- Auction automatically gets over once duration completes
- Java
- Spring Boot
- Web
- Lombok
- Netflix eureka
- Data JPA
- Config server
- AMQP
- MySQL Connector
- Tomcat
- MySQL
- RabbitMQ
- Graddle
-
Must Have:
- Java 11
- MySQL 8.0.33
- Docker 23.0.5
-
Run the RabbitMQ instance using following command:
docker run -d --hostname auction-rabbit --name auction-rabbit-container -p 15672:15672 -p 5672:5672 rabbitmq:3-management
-
Run MySQL instance on
localhost:3306
and set username and password accordingly in the properties file. -
Now, create a database with name
auction_db
-
Now run all the services security-service, cloud-config-server, cloud-gateway, security-service, auction-service in the exact sequence as mentioned.
-
Import API collection in PostMan using this link
https://api.postman.com/collections/8756666-938eaa2d-ae47-460c-b58a-91d3b4f7536f?access_key=PMAT-01H2V28EZ0F2V2MC234HTF9Q2R
-
Register Users and authenticate them to get the JWT Token and add jwts with the request
-
Now you can start auctions, start bidding on them and get running auctions by status.
URL: http://localhost:9002/auction/
Request Parameters
Request Body: itemCode, basePrice, stepRate, duration
Response
Response Body: auctionId
URL: http://localhost:9191/auction/?status={RUNNING/OVER}
Request Parameters
Query Parameters: status(running/over)
Response
Response Body: list of auctions
URL: http://localhost:9191/auction/{itemCode}/bid
Request Parameters
Path Variable: itemCode
Request Body: bidAmount
Response
Response Status:
201 - Bid is accepted
404 - Auction not found
406 - Bid is rejected
Problem: Close auction as soon as duration ends and produce winner email message from auction service using a messaging queue because only security service has the capability to send email to users
Possible Solutions
Using Mongo db and kafka together and set ttl to so that when auction duration ends it will be deleted from database and send message to kafka to send email message to email service
Reason to Reject: This approach will delete the auction from database once the duration ends
Passing messages to RabbitMQ with delayed execution parameter so that it initiates when auction is over
Reason to Reject: Auctions can last for hours and storing messages in message broker is not a good practice
Using lambda delayed execution and RabbitMQ together so that when ends lambda will start its operation make necessary changes in the database and send message to RabbitMQ to send winner email.
Reason to Reject:
Executing asynchronous threads that will wait till auction duration ends and then close the auction and send message to RabbitMQ to send winner email.
Reason to reject: Closing the program will terminate all the asynchronous threads that are waiting to close their corresponding auctions.
Scheduling a job every 20 sec to close all the running auctions that are expired and send message to rabbitmq to send winner email. In this approach, situation might occur where auction duration has ended but still the status is Running so to cop up with that we can add an additional condition in bidding service to check if the auction has expired or not.If the auction is expired no bid can be placed against this auction.
Reason to Accept: Every auction will be closed sooner or later even if one job fails next job will compensate. Additional condition will prevent users to bid on an expired auction even if it is not closed.