This application uses Java RMI and Jakarta XML Web Services to manage a distributed bookstore through Remote Method Invocations (RMI) and Remote Procedure Calls (RPC) respectively. There are three apps in this repository: the server, admin client and user client.
The server has a dual-service architecture for showcasing two distinct types of remote communication in distributed systems:
- Java RMI (Remote Method Invocation): Enables direct Java-to-Java interaction through a tightly-coupled, high-performance communication layer. The client uses this method for inter-process communication.
- JAX-WS (SOAP/RPC): Makes administrative functions available from a wider range of platforms if necessary by exposing a standardized, interoperable web service endpoint. The admin client uses this method to communicate with the server.
The User Client connects to the server using Java RMI, allowing it to invoke methods on server-side objects as if they were local. The communication between the User Client and the Server follows a standard RMI layered architecture.
- Application Layer: Represents the
User Clientand theServer's service coordination logic. - Stubs: Acts as a client's local representative or proxy for the remote object. In RMI, a stub for a remote object implements the same set of remote interfaces that a remote object implements.
- Skeletons: Responsible for dispatching the call to the actual remote object implementation.
- Remote Reference Layer: Determines how the remote object is invoked which could be determined based on replication, activation, reference behavior, etc.
- Transport Layer: Manages the low level network implementation.
JAX-WS is the protocol is used by the Admin Client. This is more standardized and interoperable than RMI. An administrative contract (WSDL) is created between the server and the client. A dynamic proxy is established by the Admin to facilitate communication between server's web service endpoint and SOAP/XML.
- WSDL to Java: The client uses the server's published WSDL (Web Services Description Language) to generate a
Service Endpoint Interface. - Get Proxy: The client uses the generated service class to request a proxy instance that implements the
RPCServiceInterface. - Invoke Method: When an admin function like
createBook(book)is called on the proxy instance, the parameters (JAXB-generated class instances) are passed to it. - SOAP Request/Response: The proxy serializes the method call into a SOAP XML request and sends it to the server's Endpoint URL. The server processes the request and returns a SOAP response.
- Return Value: The proxy deserializes the SOAP response back into a Java object and returns it to the client application.
| Area | User Client (RMI) | Admin Client (RPC) | Server |
|---|---|---|---|
| Core Function | Bookstore Browser | Inventory Management | Application & Data Engine |
| Data Rights | Read-Only | CRUD | System of Record |
| Book Operations | View, Search, Check Stock | Create, Update, Delete | Expose All Ops |
| Bulk Data | Not Supported | CSV Upload | Bulk Insert Endpoint |
| Protocol | RMI Consumer | SOAP/RPC Consumer | RMI & SOAP Provider |
| DB Access | None (via API) | None (via API) | Direct (JDBC) |
For browsing and searching the book catalog.
For managing the bookstore inventory (CRUD operations).
-
Clone the Repository
git clone git git@github.com:shama-llama/distributed-bookstore.git cd distributed-bookstore -
Build Modules
# Build server mvn clean install -f bookstore-server/pom.xml # Build admin client mvn clean install -f bookstore-admin/pom.xml # Build user client mvn clean install -f bookstore-user/pom.xml
-
Install MariaDB
sudo dnf install mariadb-server
-
Start MariaDB service
sudo systemctl start mariadb
-
Secure Installation
sudo mysql_secure_installation
-
Create Bookstore
mysql -u root -p CREATE DATABASE bookstore DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
Create Books
USE bookstore; CREATE TABLE books ( isbn VARCHAR(13) PRIMARY KEY, title VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, year INT NOT NULL, price DECIMAL(10,2) NOT NULL, quantity INT NOT NULL DEFAULT 0 );
-
Update DB Configuration
Edit
bookstore-server/src/main/resources/db.properties:db.url=jdbc:mysql://localhost:3306/bookstore db.user=root db.password=root_password
-
Start the RMI Server
cd bookstore-server mvn exec:java -Dexec.mainClass="rmi.RMIServer"
The RMI server will start on port 1099.
-
Start the RPC Server
cd bookstore-server mvn exec:java -Dexec.mainClass="rpc.RPCServer"
The RPC server will start on port 8080.
-
Run the Admin Client
cd bookstore-admin mvn exec:java -Dexec.mainClass="AdminClient"
-
Run the User Client
cd bookstore-user mvn exec:java -Dexec.mainClass="UserClient"
- MariaDB must be running for the apps to work: sudo systemctl status mariadb.
- Change the database credentials in db.properties.
- Create the bookstore database and books table before running.
- Check if ports 1099 and 8080 are being used.
- Clear Maven cache if you're getting build errors: mvn clean.
- RPC server must be running when building admin client.
This project is licensed under the terms of the MIT open source license.



