Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Command Query Responsibility Segregation (CQRS), and Event Sourcing (ES), are powerful tools. They can make the difference between an application that evolves, and remains competitive, or one that stagnates and falls into obscurity.
This course will discuss the reasons we use CQRS/ES, what benefits it provides us, but also what it will cost us to use. We will see how CQRS/ES can impact the scalability, consistency, and availability of our application. Most importantly we will learn about one of the key techniques that is used in building modern Reactive Microservices.
What is CQRS/ES Review
Question: CQRS stands for:
ES stands for:
Question: True or False: You must always use CQRS and Event Sourcing together. They can’t be used independently.
Question: You should consider using CQRS/ES if:
Note: Make sure you select all of the correct options—there may be more than one!
State Based Persistence Review
Question: State Based Persistence means:
Question: True or False: Domain requirements are fluid, rather than fixed. They can change over time depending on many factors.
Question: When using State Based Persistence, if a change needs to be made to the domain we can usually apply that change:
Question: If the persisted state in our system is incorrect due to an error in our code, we can usually:
Question: True or False: State Based Persistence captures the journey, rather than the destination.
Event Sourcing Review
Question: When using State Based Persistence, in order to recover from errors in state, or evolve our domain we can:
Question: When an audit log is stored alongside the state, we must be wary of which of the following:
Question: Which of the following is true for Event Sourcing:
Note: Make sure you select all of the correct options—there may be more than one!
Question: In an Event Sourced system, state is recovered by:
Question: True or False: If you replay events in an Event Sourced system, you must also replay the side effects.
Question: A snapshot should be created:
Question: Benefits of Event Sourcing include:
Note: Make sure you select all of the correct options—there may be more than one!
Question: In the Lightbend Ecosystem you can find Event Sourcing in:
Evolving the Model Review
Question: Which of the following statements is FALSE:
Question: If you need to evolve your data model, you should do so by:
Question: True or False: Java Serialization is an excellent choice for serializing your events.
Question: Versioning of Events can be handled in the Lightbend ecosystem using:
Command Sourcing Review
Question: When using Command Sourcing, the order we do things is:
Question: Which of the following are potential challenges with Command Sourcing:
Note: Make sure you select all of the correct options—there may be more than one!
Question: True or False: Akka Persistence can be used to implement Command Sourcing.
Case Study: Reactive BBQ Events
Question: Using this existing table structure, can we determine how often an order is cancelled either before, or after it has been placed?
Question: Which of the following events would the Reactive BBQ Order system need to track in order to determine how often an order is cancelled either before, or after it has been placed?
Note: Make sure you select all of the correct options—there may be more than one!
Question: Which of the following problems might they encounter while trying to determine if people are ordering drinks after tasting their Reactive Wings or ReactiveRibs?
Note: Make sure you select all of the correct options—there may be more than one!
Question: If we simply added timestamps to the Order Items Table, would that solve our problem?
Question: What events would we need to track in order to determine if a drink is being added after our wings or ribs are served?
Note: Make sure you select all of the correct options—there may be more than one!
Read Models Vs Write Models Review
Question: Which of the following is a potential problem in an Event Sourced system:
Question: True or False: The problem of conflicting models in our system is unique to Event Sourced systems.
Question: Fundamentally, the problem that we have encountered with these conflicting models is:
CQRS Review
Question: True or False: The requirements for read and write in our system should be more or less the same.
Question: Most applications tend to have:
Question: In a CQRS based system, the Commands are handled by the:
Queries are handled by the:
Question: True or False: Event Sourcing is critical for CQRS systems. You can’t use CQRS without Event Sourcing.
Question: When building a system with both CQRS and Event Sourcing, the components we normally include are:
Note: Make sure you select all of the correct options—there may be more than one!
Question: True or False: An ideal read model is often setup so the data can be read directly from a single table in the database, as is, with minimal additional processing/formatting.
Question: Polyglot Persistence means:
Question: Which of the following is a disadvantage of using CQRS:
Question: A key benefit to combining CQRS and Event Sourcing is:
Question: In the Lightbend Ecosystem, CQRS can be implemented using:
Note: Make sure you select all of the correct options—there may be more than one!
Case Study: Reactive BBQ Read Models
Question: Assuming we had access to the above events, what table structure could we use to answer the question “how often are orders cancelled after they are placed”?
Note: Make sure you select all of the correct options—there may be more than one!
Question: Which of these table structures would provide the most efficient query?
Question: Assuming we had access to the above events, what table structure could we use to answer the question “how often do customers order milk after being served Reactive Wings or Ribs”?
Note: Make sure you select all of the correct options—there may be more than one!
Question: Which of these table structures would provide the most efficient query?
Fine Grained Microservices Review
Question: True or False: In a CQRS/ES based system, the read and write models should always live in the same microservice.
Question: True or False: Microservices are cheap and easy. We shouldn’t have to worry about adding new ones.
Consistency, Availability & Scalability with CQRS Review
Question: Simple CQRS (without event sourcing) promises what kind of consistency?
Question: CQRS with Event Sourcing promises what kind of consistency?
Question: Strong Consistency is most important for:
Question: Pure reads are:
Question: Which of the following options could be used to scale a read model?
Question: True or False: The write side of CQRS systems require Strong Consistency, and therefore are inherently not scalable.
Question: True or False: Strongly Consistent write models require sacrifices in availability.
Question: Options to provide availability in a CQRS system include:
Note: Make sure you select all of the correct options—there may be more than one!
Cost of CQRS Review
Question: True or False: CQRS takes concepts that would commonly be isolated in a single large class or model, and spreads them across multiple smaller classes or models.
Question: CQRS is often considered to be more complex because:
Question: True or False: The Eventual Consistency introduced by CQRS based systems was actually always there. CQRS just makes it more explicit.
Question: Some concrete costs associated with using CQRS and Event Sourcing include:
Note: Make sure you select all of the correct options—there may be more than one!
Question: When data between the read and write model is out of sync, we can:
Case Study: Reactive BBQ Scenarios
Question: Some possible reasons this problem exists include:
Question: In the new system, they could avoid this problem by:
Question: True or False: The data on the screen must be strongly consistent to avoid potential errors in the order.
Question: In order to ensure that the information on the screen is always available we could:
Question: Which parts of the existing system would have already experienced Eventual Consistency?
Question: Which parts of the new system will need strong consistency (given that they have expressed a desire for consistency)?
Final Exam
Question: Scalable Games is an online gaming company. They have built a new game that they are hoping will have millions of users.
The game they are building is a strategy title where users can play asychronously. A user may create their kingdom, and attack other users, but those attacks are carried out without requiring input from either user.
To achieve this, when a user wants to attack another user, they submit a request to the server to perform the attack. The server will acknowledge that it has received the request, but the actual execution of the request will happen asynchronously. The request will be added to a queue, and when the server is ready, it will perform the attack and then notify both users once it has determined the result.
The game server is leveraging a(n) _______ sourced model.
Answer: Command
Question: CQRS Auto is a automobile trading company formed in the 1980s by four partners (Christa, Quentin, Rhonda, and Samuel). They have since grown to be one of the largest auto traders in the nation.
The company allows users to post an advertisement for a vehicle that they want to sell. They can create the ad, attach pictures, add descriptions, set the price etc.
Once their ad has been created, it will be asynchronously added to the CQRS Auto website. On the website, other users can filter the vehicles, compare them, and look at the details.
When creating an ad, users would be interfacing with the _______ model, or the _______ side of the CQRS system.
Answer: Write
When viewing ads, users would be interfacing with the _______ model, or the _______ side of the CQRS system.
Answer: Read
Question: Saga Electronics is an online retailer focusing on Electronics.
A critical part of their business is the payment service. They use a third party payment processor to handle all transactions, however, it is still critical that they keep internal records which are then reconciled with the records from the payment processor.
In order to do this, each time a payment is made, they enter the details of that payment into a log. This log can then be reconciled against any logs that come back from the payment processor. If a discrepancy is found then they will have to perform an audit to determine why there is a difference.
The integrity of this log is critical. For that reason, they require that the log be append only. If a correction needs to be made, then they will make that correction by adding an additional log entry, rather than editing an existing one.
Saga Electronics could leverage _______ to maintain their log.
Answer: Event Sourcing
Question: Spectrum Messages has created an online messaging platform.
One of the features of their platform is the ability to broadcast messages to a large number of users. A user can create a message that will be shared with a group, rather than an individual.
When a group message is sent, there is no guarantee that every receiver will be online at the time. They may have their phone turned off, the app may be disabled, or they may not have internet access.
The sender can create their messages using _______ Consistency.
Answer: Strong Consistency
The receivers will receive the messages using _______ Consistency.
Answer: Eventual Consistency
Question: Consistent Fitness has built a wearable fitness tracker. Users push data from their fitness tracker up to the company servers. This data is then stored in a raw form.
One of the goals of the company is to create a series of rich insights about their users. These insights are presented to the users through a dashboard. They allow users to learn things about their own fitness habits such as how often they exercise in a week, how their heart rate changes when they exercise etc.
They have a series of asynchronous processes which will consume the raw data, and aggregate it in various ways. This allows them to take the raw user data, and create new insights. And because they always have access to the raw data, these insights can be retroactive.
Consistent Fitness is levaragine what technique?
Answer: CQRS
We hope you know the correct answers to Reactive Architecture: CQRS & Event Sourcing If Queslers helped you to find out the correct answers then make sure to bookmark our site for more Course Quiz Answers.
If the options are not the same then make sure to let us know by leaving it in the comments below.
In our experience, we suggest you enroll in this and gain some new skills from Professionals completely free and we assure you will be worth it.
This course is available on Cognitive Class for free, if you are stuck anywhere between quiz or graded assessment quiz, just visit Queslers to get all Quiz Answers and Coding Solutions.
More Courses Quiz Answers >>
Building Cloud Native and Multicloud Applications Quiz Answers