HomeApache Geronimo v2.0 > Documentation > Sample applications > DayTrader

Apache DayTrader Benchmark Sample

What is DayTrader?

DayTrader is benchmark application built around the paradigm of an online stock trading system. Originally developed by IBM as the Trade Performance Benchmark Sample, DayTrader was donated to the Apache Geronimo community in 2005. The application allows users to login, view their portfolio, lookup stock quotes, and buy or sell stock shares. With the aid of a Web-based load driver such as Mercury LoadRunner, Rational Performance Tester, or Apache JMeter, the real-world workload provided by DayTrader can be used to measure and compare the performance of Java Platform, Enterprise Edition (Java EE) application servers offered by a variety of vendors. In addition to the full workload, the application also contains a set of primitives used for functional and performance testing of various Java EE components and common design patterns.

Application Architecture

DayTrader is built on a core set of Java EE technologies that includes Java Servlets and JavaServer Pages (JSPs) for the presentation layer and Java database connectivity (JDBC), Java Message Service (JMS), Enterprise JavaBeans (EJBs) and Message-Driven Beans (MDBs) for the back-end business logic and persistence layer. The following diagram provides a high-level overview of the full workload application architecture.

Presentation Layer

The presentation layer consists of several Java Servlets and JSPs that loosely adhere to a Model-View-Controller (MVC) design pattern. TradeAppServlet is the primary controller servlet responsible for recieving incoming client requests, triggering the desired business logic, and forwarding responses to the appropriate JSP page. Additional servlets and JSPs are used to configure the DayTrader runtime options and manage the supporting database.

Business Logic and Persistence Layer

The business logic and persistence layer form the bulk of the DayTrader application. The TradeServices interface defines the core set of business operations available in the application, such as register, login, getHoldings, buy, completeOrder, logout, etc. DayTrader provides three different implementations of these services, corresponding to three commonly used JavaEE application design patterns. These implementations are discussed below. Users can switch between these implemenations on the configuration page by changed the Runtime Mode.

Implementation Details
TradeDirect
(Default)
Pattern: Servlet-to-JDBC
Runtime Mode: Direct

The TradeDirect class performs CRUD (create, read, update, and delete) operations directly agaist the supporting database using custom JDBC code. Database connections, commits, and rollbacks are managed manually in the code. JTA user transactions are used to coordinate 2-phase commmits.
TradeJDBC Pattern: Servlet-to-SessionBean-to-JDBC
Runtime Mode: Session Direct

The TradeJDBC stateless session bean serves as a wrapper for TradeDirect. The session bean assumes control of all transaction management while TradeDirect remains responsible for handleing the JDBC operations and connections. This implementation reflects the most commonly used JavaEE application design pattern.
TradeBean Pattern: Servlet-to-SessionBean-to-EntityBean
Runtime Mode: EJB

The TradeBean stateless session bean uses Caontainer Managed Persistence (CMP) entity beans to represent the business objects. The state of these objects is completely managed by the application servers EJB container.

Another subtle component of this layer involves the Java Messaging Service (JMS). JMS is used within DayTrader for two specific purposes, asynchronously processing buy/sell orders, and publishing quote price updates. The following table discusses these operations in further detail.

Operation Details
Asynchrounous Order Processing When a buy or sell operation is performed, an order request is placed on the TradeBroker JMS queue using a client connection. The TradeBrokerMDB consumes messages on this queue and completes the buy or sell operation.
Quote Price Updates As stocks are traded, the associated quote prices are updated in the database and published to a JMS topic. The TradeStreamerMDB subscribes to these updates consuming the price updates messages, but does nothing more with them. The TradeStreamer JavaEE client that is bundled with DayTrader can be started to view the quote prices updates in real time.

Getting the source

http://svn.apache.org/repos/asf/geronimo/daytrader/trunk