-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The distributed banking system is made up of the following micro-services:
-
Banking API Service: This is the entry point to the system. It receives customer card transactions from retailers and produces messages to the appropriate Kafka topics for processing by the other services. In a real system, this would receive transactions from a front-end GUI application or another banking system. In our simplified version, it reads customer transactions from a text file using the provided
IncomingTransactionsReader.IncomingTransactionsReaderprovides methods similar to standard Java file IO to assist in reading customer transaction information:-
public boolean hasNext(): return true if there is another transaction to read -
public Transaction next(): reads the next transaction
Each
Transactioncontains the following information:- User: the username of the user who made the purchase in that particular store
- Amount: the amount of the purchase transaction
- Transaction Location: the country in which the purchase transactions took place.
-
-
Customers Database: A database where we store each of our bank customers' home location. In a real system this would connect to a real database. In our simplified version it reads customer address information from a text file using the provided
CustomerAddressDatabase, which maps user names to address locations.CustomerAddressDatabaseprovides the methodpublic String getUserResidence(String user), which returns the address location for a given user. -
User Notification Service: receives notifications of suspicious transactions that require customer approval.
-
Account Manager Service: receives notifications of valid transactions which can be processed normally (debit money from the customer's account to the stores account).
-
Reporting Service: receives notifications of all transactions received by the Banking API Service for further processing.
All the communication between these micro-services is achieved using Kafka Topics.
The distributed banking system communicates using a fault-tolerant and scalable Kafka cluster set up as follows:
- 3 Kafka brokers listening on ports 9092, 9093 and 9094
- A topic called
valid-transactionswith 3 partitions and a replication factor of 3. - A topic called
suspicious-transactionswith 2 partitions and a replication factor of 3.
When set up correctly, the output of the kafka-topics script's --describe command for the two topics should look
something like this:
Topic: valid-transactions PartitionCount: 3 ReplicationFactor: 3 Configs: segment.bytes=1073741824
Topic: valid-transactions Partition: 0 Leader: 1 Replicas: 1,0,2 Isr: 1,0,2
Topic: valid-transactions Partition: 1 Leader: 0 Replicas: 0,2,1 Isr: 0,2,1
Topic: valid-transactions Partition: 2 Leader: 2 Replicas: 2,1,0 Isr: 2,1,0
Topic: suspicious-transactions PartitionCount: 2 ReplicationFactor: 3 Configs: segment.bytes=1073741824
Topic: suspicious-transactions Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,0,1
Topic: suspicious-transactions Partition: 1 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
Starter code was given for the micro-services with some parts of the functionality implemented. The task was to complete the implementation of each service, as described below:
-
bank-api-service- Processes customer transactions from a text file using the
IncomingTransactionsReaderclass. Processing transactions involves:- Identifying the customer the transaction applies to using the
userfield ofTransaction - Retrieving this customer's home address from the
CustomerAddressDatabase. - Compare the transaction location with the customer's home address, and send a message to the appropriate Kafka
topic:
- If the locations match then it's a valid transaction and the message should be sent to
the
valid -transactionstopic. - If the locations don't match then it's a suspicious transaction and the message should be sent to the
suspicious-transactionstopic.
- If the locations match then it's a valid transaction and the message should be sent to
the
- The Kafka messages should have the following structure:
- Key: user (String)
- Value: Transaction
- The classes
IncomingTransactionsReader,CustomerAddressDatabase, andTransactionare provided for you. You'll need to complete the implementation of thebank-api-service.
- Identifying the customer the transaction applies to using the
- Processes customer transactions from a text file using the
-
user-notification-service- Receives Kafka messages with information on suspicious transactions from the
suspicious-transactionstopic. - Prints suspicious transaction information to the screen.
- You'll need to complete the implementation of this service.
- Receives Kafka messages with information on suspicious transactions from the
-
account-manager- Receives Kafka messages with information on valid transactions from the
valid-transactionstopic. - Prints valid transaction information to the screen.
- You'll need to complete the implementation of this service.
- Receives Kafka messages with information on valid transactions from the
-
reporting-service- Receives Kafka messages with information on all transactions from the
valid-transactionsandsuspicious-transactionstopics. - Prints all transaction information to the screen, using a different message for suspicious and valid transactions.
- You'll need to complete the implementation of this service.
- Receives Kafka messages with information on all transactions from the
