Skip to content

Day 4 / Apr 22 (Fri)

Morning Exercise

Exercise: Using Consumer Group

After completing the exercise, run multiple instances of your Kafka consumer application (you should have one developed already) and observe what partitions they consume. Modify the application to print out record values and partitions to the standard output (console).

Theory

  1. Kafka Consumers, Consumer Groups, and Partition Rebalancing

Practice

Honing our skills in Object-Oriented Programming in Scala.

For every exercise do the following:

  1. Write tests
  2. Publish to Github

Exercise 1

Write the following classes so, when executed, use something instance-specific:

  1. Logger that prints out a message with a log prefix
  2. Sender that sends out a message with a message header

"Executed" means "called" by a "caller".

Exercise 2: Bank

Write a Bank class that may have one or more Accounts.

An Account has a balance and a number.

  1. You can make a deposit and a withdraw of a specified amount
    • Handle insufficient funds to withdraw
    • Is it enough to return a boolean value to indicate a failure?
  2. You can print a statement for an account
  3. You can close an account (which is to make a balance zero)

Define transfer method to transfer money from one account to another (only when there is enough money).

Exercise 3: Currency Exchange

Define a Kantor class with the following properties:

  1. A customer can open one or more currency accounts
  2. A customer can exchange one currency to another (between accounts) according to exchange rate table published at regular intervals

Exercise 4: Speaking Languages

A person can speak different languages.

Write a Person class that can say hello in as many languages as it knows (e.g. English, French, Polish, German).

A person can report what languages it can speak.

Two people can talk only when they speak at least one language they both can speak.

Homework

  1. Complete the Exercises
  2. Exercise: Partition Leader Election and Consumer Fail-Over
Back to top