0
0
Kafkadevops~10 mins

Saga pattern for distributed transactions in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the first step in a saga transaction.

Kafka
producer.send('[1]', message);
Drag options to blanks, or click blank then click option'
Aorder-created-topic
Bpayment-processed-topic
Cinventory-updated-topic
Dshipment-scheduled-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a topic for a later step in the saga.
2fill in blank
medium

Complete the code to consume messages for compensating transactions.

Kafka
consumer.subscribe(['[1]']);
Drag options to blanks, or click blank then click option'
Aorder-created-topic
Bpayment-compensate-topic
Cinventory-updated-topic
Dshipment-scheduled-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Subscribing to the wrong topic that is not for compensation.
3fill in blank
hard

Fix the error in the code that sends a compensation message.

Kafka
producer.send('[1]', compensationMessage);
Drag options to blanks, or click blank then click option'
Apayment-processed-topic
Border-created-topic
Cpayment-compensate-topic
Dinventory-updated-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Sending compensation messages to the wrong topic.
4fill in blank
hard

Fill both blanks to correctly define the saga step and its compensation topic.

Kafka
const sagaStep = '[1]';
const compensationTopic = '[2]';
Drag options to blanks, or click blank then click option'
Ainventory-updated-topic
Bpayment-compensate-topic
Corder-compensate-topic
Dshipment-scheduled-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up saga step topics with compensation topics.
5fill in blank
hard

Fill all three blanks to correctly map the saga steps to their compensation topics.

Kafka
const steps = {
  order: '[1]',
  payment: '[2]',
  inventory: '[3]'
};
Drag options to blanks, or click blank then click option'
Aorder-compensate-topic
Bpayment-compensate-topic
Cinventory-compensate-topic
Dshipment-compensate-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning wrong compensation topics to steps.