Assignment 3 - JMS

Implement an online trading application. Each running instance communicates with other running instances and also with the bank.

The assignment describes a message-based communication protocol that implements a simple trading system. Understanding the assignment requires no special knowledge.

Parts of the implementation are provided. Download source code from https://d3s.mff.cuni.cz/files/teaching/nswi080/labs/Files/sources-3.zip

Prerequisites

The chosen messaging standard is JMS (Java Message Service), using the ActiveMQ 5.16 or ActiveMQ Artemis 2.17 implementation. The following knowledge is needed for the implementation:

Your task

Application must provide the following functionality:

  1. After its startup, create random unique names of goods, that the user (seller) provides, together with random price of each item. This list should be sent as a message via the Offers topic to the other running instances.

    The application should also send the Bank a message requesting account creation. The bank will respond with a message containing the account number.

  2. Present to the users (in any trivial form) a list of goods and prices, offered by the other running instances. This list should be updated, whenever a new message from the Offers topic arrives, and any items no longer offered by the sending instance should be removed from the list.

  3. Allow the user to choose (again, using any trivial method) goods to buy from another instance. The sale is realized as follows:

    Note: The buyer does not have to offer the item bought for sale.

  4. Consider the weaknesses of the communication protocols described above. Extend, document and implement a more robust variant of the protocol (reusing the provided parts is allowed) that will have these features:

The messages used to implement the functionality may contain further information that might be needed but not mentioned above. You are to choose the appropriate message types. (For example, the provided Bank implementation uses TextMessage and MapMessage, you are free to choose different types for the communication between the client instances.)

The implementation should behave reasonably when possible - refuse to sell an item already requested by a different buyer, etc.

Notes

Implementation

Common problems

Exceptions at client start-up

Provided parts of the solution

Basic procedure of goods offers

Basic procedure of buying goods

Common mistakes

Submission