Skip to content

ibm-messaging/eventstreams-badge-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Streams on Cloud Essentials coding challenge

This coding challenge is part of the Event Streams on Cloud Essentials course.

In this challenge, we will first run a small binary application. This application will produce some records to a topic. Then, the task is to:

  • write a consumer application that will consume records from the topic
  • recover the secret message put inside one of the records

Prerequisite

The Challenge

The challenge is to produce messages by running the producer binary application provided and modify the consumer application to find the secret message.

The producer application will create a topic called event-streams-coding-challenge and send records, one of which is the secret message.

The next step will be to edit the example App.java application and add a poll loop in order to keep consuming records until it finds the secret message. The secret message is the value of the record that has the following key: coding-challenge.

Follow these steps to complete the challenge:

  1. Get the challenge code. Click the clone or download button. You can choose to Clone with SSH, Use HTTPS, or Download ZIP with the code. Clone or unzip the repository.

  2. Run the producer application by providing the broker address and API key found from your Event Streams Service credentials.

java -jar coding-challenge-setup.jar <kafka_broker_sasl> <api_key>

Ensure you see "Congratulations! You have successfully setup the topic for the coding challenge." in the output to confirm the secret message was correctly written to the topic.

Now it's time to try to recover the secret message!

  1. Setup a project for the sample consumer application

First, navigate to the coding-challenge-consumer directory:

cd coding-challenge-consumer

Then create a project for your preferred IDE:

gradle eclipse

Or

gradle idea

Finally import the consumer project into your IDE.

  1. In the IDE, open App.java and modify the code where you see TODO comments.

There are 4 TODO comments that highlight Consumer logic that is required to complete the challenge.

// TODO Move position to beginning of partition
// TODO: Add consumer poll loop
// TODO: Find the record whose key is equal to KEY ("coding-challenge")
// TODO: Print the record value to discover the secret message
  1. Once you have finished modifying the consumer code, build the application.
gradle clean && gradle build
  1. Run the consumer application.
java -jar ./build/libs/coding-challenge-consumer.jar <kafka_broker_sasl> <api_key>

If your code does not work, don't panic! Just return to step 4 and rerun steps 5 and 6 after you've made changes.

If you get stuck, review the explanations of the Event Streams sample in Get hands on experience with Event Streams Java sample as it contains all the logic required to complete the challenge.

Summary and next steps

Congratulations! You’ve successfully written your first Kafka application and completed the challenge. Be sure that you’ve checked out the Event Streams cheat sheet, because it’s packed full of ninja moves that every Event Streams user should know.

If you’re all done and ready to take the quiz and earn your IBM Event Streams Developer Essentials badge, go back to the IBM Event Streams Developer Essentials badge page and click through to the quiz!

About

Coding challenge for the Event Streams on Cloud Essentials badge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages