Final Assignment – A robust, enterprise-grade Online Auction System built with Jakarta EE, packaged as an EAR, leveraging ActiveMQ for async messaging and tested using JMeter and VisualVM.
This system enables users to list items for auction, place bids in real time, and receive notifications when auctions conclude. Key features:
- Modular Architecture: Core entities, EJB business logic, web APIs, and EAR packaging.
- Asynchronous Messaging: Notify winners and sellers via JMS queue (ActiveMQ).
- Performance Testing: Validate scalability with Apache JMeter and profile JVM with VisualVM.
The repository follows an Enterprise Archive (EAR) structure:
Online-Auction-System/
├── core/ # JAR: JPA entities (User, Item, Auction, Bid), DTOs, DAOs
├── ejb/ # EJB JAR: Stateless beans (AuctionServiceBean, BidServiceBean), JMS producers
├── web/ # WAR: JAX-RS REST endpoints under /api (UserResource, AuctionResource, BidResource)
├── ear/ # EAR: Aggregates core, ejb, web; contains application.xml & JMS resource descriptors
├── pom.xml # Parent POM defining modules & dependency management
├── .gitignore
└── README.md # This document
- Entities:
User
,Item
,Auction
,Bid
with JPA annotations. - DAOs: Generic CRUD operations via
EntityManager
. - DTOs: Data transfer objects for REST payloads.
-
AuctionServiceBean
(@Stateless
): Create auctions, close auctions. -
BidServiceBean
(@Stateless
): Place bids with concurrency control. -
JMS Producer: Sends messages to notify users when auctions close.
@Resource(lookup = "jms/AuctionConnectionFactory") private ConnectionFactory cf; @Resource(lookup = "jms/AuctionQueue") private Queue queue; public void notifyAuctionEnd(Auction auction) { try (JMSContext context = cf.createContext()) { context.createProducer() .send(queue, auction.getId().toString()); } }
-
JAX-RS Resources:
UserResource
for registration and login.AuctionResource
to list/create auctions.BidResource
to place bids (POST /api/auctions/{id}/bids
).
-
Security: Basic authentication (EJB interceptor or Jakarta Security).
-
application.xml
: Defines modules and context roots. -
JMS Resources: Included in
META-INF
for server configuration:<resource-ref> <res-ref-name>jms/AuctionQueue</res-ref-name> <res-type>javax.jms.Queue</res-type> </resource-ref>
Apache ActiveMQ is our JMS broker for reliable, asynchronous messaging.
-
Setup Broker:
brew install activemq # MacOS, or download ZIP for Windows/Linux activemq start # Starts broker at tcp://localhost:61616
-
Define Resources in
broker.xml
:<queue physicalName="AuctionQueue" />
-
Producer Example: See
ejb/src/main/java/.../AuctionServiceBean.java
above. -
Consumer Example: A separate EJB MDB listening on
jms/AuctionQueue
:@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName="destination", propertyValue="AuctionQueue"), @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue") }) public class AuctionNotificationMDB implements MessageListener { public void onMessage(Message msg) { String auctionId = msg.getBody(String.class); // Lookup winning bid and email user... } }
Load-test REST endpoints to simulate high traffic:
-
Design Test Plan: Thread Group → HTTP Requests → Listeners.
-
Sample Command (Non-GUI):
jmeter -n -t AuctionTest.jmx \ -l AuctionResults.jtl -e -o AuctionReport
-
Key Metrics: Throughput, Response Time, Error Rate.
-
Importance: Validates scalability, identifies bottlenecks.
Profile JVM performance in real time:
- Launch VisualVM: bundled with JDK or standalone.
- Attach to running App Server process.
- Monitor: CPU, Heap, Threads, and perform Heap Dumps.
- Profiler: Drill down into hot methods in EJBs and DAOs.
- Importance: Detect memory leaks, thread contention, and heavy CPU usage.
-
Build All Modules:
mvn clean install
-
Deploy EAR:
asadmin deploy ear/OnlineAuctionSystem.ear
-
Start ActiveMQ (see above).
-
Access API:
http://localhost:8080/auction-web/api
MIT © 2025 Tharindu714 Questions? Email: contact@example.com
Ready to bid? 🏷️ Happy coding and good luck on your final assignment!