A Multi-Agent System (MAS) built with the JADE (Java Agent DEvelopment Framework), where autonomous software agents negotiate with each other to buy and sell books.
This is not a traditional web application. There is no central server. Instead, independent autonomous agents communicate, negotiate, and trade using FIPA (Foundation for Intelligent Physical Agents) standard messaging protocols.
- Fundamentals of Agent-Oriented Programming
- JADE Framework usage and agent lifecycle
- FIPA ACL (Agent Communication Language) messaging protocol
- Behaviour models:
TickerBehaviour,CyclicBehaviour,OneShotBehaviour - Yellow Pages service discovery via the Directory Facilitator
- Negotiation protocol: CFP (Call for Proposal) → PROPOSE → ACCEPT_PROPOSAL → INFORM
Buyer Agent Directory Facilitator Seller Agent(s)
| | |
| 1. Search | |
| "book-selling" | |
|----------------------->| |
| | |
| 2. Return seller list | |
|<-----------------------| |
| |
| 3. CFP: "Do you have Java 101?" |
|-------------------------------------------------->|
| |
| 4a. PROPOSE: "Price: 50" |
|<--------------------------------------------------|
| 4b. REFUSE: "not-available" |
|<--------------------------------------------------|
| |
| [Select lowest price] |
| |
| 5. ACCEPT_PROPOSAL: "I'll buy Java 101" |
|-------------------------------------------------->|
| |
| 6a. INFORM: "Purchase successful" |
|<--------------------------------------------------|
| 6b. FAILURE: "Already sold" |
|<--------------------------------------------------|
BookTrading/
├── src/booktrading/
│ ├── BookBuyerAgent.java # Buyer agent - searches for and purchases books
│ ├── BookSellerAgent.java # Seller agent - manages catalogue and handles sales
│ ├── BookSellerGui.java # Swing GUI for the seller agent
│ └── BookTrading.java # Main class (entry point)
├── dist/
│ ├── BookTrading.jar # Compiled JAR file
│ └── lib/
│ ├── jade.jar # JADE framework library
│ └── commons-codec-1.3.jar
├── build.xml # Apache Ant build script
└── nbproject/ # NetBeans IDE configuration
An autonomous agent that searches for and purchases a target book.
| Property | Description |
|---|---|
| Behaviour | TickerBehaviour - searches for sellers every 60 seconds |
| Strategy | Sends CFP to all sellers, accepts the lowest price offer |
| Startup Argument | Target book title (e.g. "Java 101") |
| Termination | Shuts down automatically after a successful purchase |
Key Behaviours:
TickerBehaviour: Periodically queries the Directory Facilitator for available sellersRequestPerformer(inner class): A 4-step state machine that drives the negotiation
An agent that manages a book catalogue and handles incoming sales.
| Property | Description |
|---|---|
| Catalogue | Hashtable<String, Integer> - maps book title to price |
| Service Registration | Registers as "book-selling" in the Directory Facilitator |
| GUI | Uses BookSellerGui for adding books via a graphical interface |
Key Behaviours:
OfferRequestsServer(CyclicBehaviour): Responds to CFP messages with a price proposal or refusalPurchaseOrdersServer(CyclicBehaviour): Processes purchase orders, removes sold books from catalogue
A Swing-based graphical interface for the seller agent.
- Text fields for book title and price
- "Add" button to insert books into the catalogue
- Closing the window terminates the agent
| Requirement | Version |
|---|---|
| Java JDK | 1.8 or higher |
| Apache Ant | 1.8.0+ (for building) |
| JADE | 4.5.0 (included in dist/lib/) |
Run the full demo with a single command (seller + buyer agents):
cd BookTrading/dist
java -cp "lib/jade.jar:lib/commons-codec-1.3.jar:BookTrading.jar" \
jade.Boot -gui \
"seller1:booktrading.BookSellerAgent;buyer1:booktrading.BookBuyerAgent(Java 101)"This will open:
- JADE RMA - the platform management GUI
- Seller GUI - add books here (title + price → click Add)
- Buyer Agent - automatically searches for "Java 101" every 60 seconds
Add Java 101 with any price in the Seller GUI and watch the buyer purchase it automatically.
If you want to recompile the project:
cd BookTrading
ant clean build
ant jarcd BookTrading/dist
# Option 1: Platform only (create agents manually via RMA GUI)
java -cp "lib/jade.jar:lib/commons-codec-1.3.jar:BookTrading.jar" \
jade.Boot -gui
# Option 2: Platform + seller agents
java -cp "lib/jade.jar:lib/commons-codec-1.3.jar:BookTrading.jar" \
jade.Boot -gui \
"seller1:booktrading.BookSellerAgent;seller2:booktrading.BookSellerAgent"
# Option 3: Full demo (seller + buyer)
java -cp "lib/jade.jar:lib/commons-codec-1.3.jar:BookTrading.jar" \
jade.Boot -gui \
"seller1:booktrading.BookSellerAgent;buyer1:booktrading.BookBuyerAgent(Java 101)"From the JADE RMA (Remote Management Agent) GUI:
- Go to Actions → Start New Agent
- Agent Name:
buyer1 - Class Name:
booktrading.BookBuyerAgent - Arguments:
Java 101(the book title to search for)
When a seller agent starts, a GUI window will open:
- Enter a book title in the Book title field (e.g.
Java 101) - Enter a price in the Price field (e.g.
50) - Click Add
The buyer agent will discover this book within 60 seconds and automatically initiate the purchase process.
Seller-agent seller1@localhost:1099/JADE is ready.
Java 101 inserted into catalogue. Price = 50
Hallo! Buyer-agent buyer1@localhost:1099/JADE is ready.
Target book is Java 101
Trying to buy Java 101
Found the following seller agents:
seller1@localhost:1099/JADE
Java 101 successfully purchased from agent seller1@localhost:1099/JADE
Price = 50
Buyer-agent buyer1@localhost:1099/JADE terminating.
| Term | Description |
|---|---|
| Agent | An autonomous, goal-driven software entity |
| Behaviour | A unit of work that an agent performs |
| ACL Message | Agent Communication Language message (FIPA standard) |
| CFP | Call for Proposal - a request for price offers |
| PROPOSE | A price offer reply |
| ACCEPT_PROPOSAL | Acceptance of a seller's offer |
| INFORM | Confirmation that a transaction completed successfully |
| REFUSE | Rejection (requested item not available) |
| FAILURE | Transaction failed (item already sold) |
| Directory Facilitator (DF) | Yellow pages service where agents register their services |
| RMA | Remote Management Agent - JADE platform management GUI |
| FIPA | Foundation for Intelligent Physical Agents - agent standards body |
| MAS | Multi-Agent System |
This project is based on JADE examples and is licensed under the GNU Lesser General Public License v2.1.