Skip navigation links
Berkeley DB Java Edition Examples
version 7.5.11

Package je.rep.quote

JE Replication Stock Quote example.

See: Description

Package je.rep.quote Description

JE Replication Stock Quote example.

Example Overview

This example is a simple but complete demonstration of a replicated application. The application is a mock stock ticker which stores stock values in a replicated JE environment. The following commands are accepted:

There are three versions of the example which illustrate different application designs and aspects of JE functionality. Please be sure to walk through the three examples in the order listed below, since the information in one example builds on the one before it. The javadoc description for each class describes the example and explains how to run it. More detailed information is found in the example source code.

  1. StockQuotes: This example is the most basic demonstration of a replicated application. It's intended to help gain an understanding of basic HA concepts and demonstrate use of the HA APIs to create a replicated environment and issue read and write transactions.

  2. RouterDrivenStockQuotes and HARouter: This example is based on StockQuotes and illustrates use of an HA-aware router (implemented by HARouter), in conjunction with the Monitor class, to direct application requests, based upon the type of request (read or write) and the state (Master or Replica) of a node in the replication group. This example is meant to illustrate how a software load balancer might be integrated with JE HA, where HARouter plays the role of the load balancer for purposes of the example.

  3. UpdateForwardingStockQuotes and SimpleRouter: This example is based on RouterDrivenStockQuotes and illustrates use of an HA unaware router (implemented by SimpleRouter), that load balances requests (both read and write) across all the nodes in a replication group. This example is meant to illustrate how a load balancer appliance might fit into the JE HA architecture, where SimpleRouter plays the role of the load balancer appliance for purposes of the example.
Disclaimer: This example is intended to be illustrative. The example is single threaded, while actual applications may be multithreaded. The example forwards requests as text and receives responses in text form, while actual applications may for example, forward HTTP requests, or use some other application level network protocol to forward such requests. The example opens and closes a socket to send each request, while actual applications will typically use a connection management facility.

The example StockQuotesRMIForwarding, a minor variation to the basic StockQuotes example is also included in this package. It's intended to help illustrate how RMI could be used to forward write requests from a Replica to the Master.

Skip navigation links
Berkeley DB Java Edition Examples
version 7.5.11

Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.