* Archietecture Diagram added * Added pom.xml * Architecture Diagram Updated * Added Microservices and kafka * ReadME File Added * ReadME file Updated * #1329 ReadMe file updated and working pattern code added * #1329 readme file updated * #1329 readme file updated and java documentation added * #1329 repository merged * Update claim-check-pattern/ReadME.md #1329 Real world description updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Applicability section in ReadMe file updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Tutorial section in ReadMe file updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Storage Data section in ReadMe File updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 workflow section Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/pom.xml Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 deleted mvnw.cmd file * #1329 deleted drawio file * #1329 deleted mvnw file * #1329 deleted mvnw file * #1329 mvnw.cmd file deleted * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/MessageHeader.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageCostDetail.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageDetail.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 deleted mvnw file * #1329 deleted mvnw.cmd file * #1329 Update claim-check-pattern/usage-detail-sender/src/main/java/com/callusage/domain/Message.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 pom file dependencies fixed, readmeflie updated, removed unused imports * #1329 Readfile updated, class javadoc added * #1329 UML class diagrams added, readme file updated * #1329 lombok annotations used on model classes, common dependencies moved to parent pom * #1329 test cases added * include claim-check-pattern in parent pom * #1329 code smells fixed * #1329 code smells removed * #1329 security issues fixed * #1329 updated pom files and refactored packages name * #1329 checkstyle warning fixed * #1329 code coverage increased * #1329 minor changed. * checkpoint created with common utility * Claim-Check-Pattern | Shrirang97 | Implemented using Java Azure Functions * Claim-Check-Pattern | Shrirang97 | Updated Functions logic * Update MessageHandlerUtility.java * Update UsageCostProcessorFunction.java * claim-check-pattern | Shrirang97 | Added test cases * claim-check-pattern | Shrirang97 | Test cases for Azure functions fixed * Claim-Check-Pattern | Shrirang | Used string as request body * claim-check-pattern | Shrirang | Working test cases * claim-check-pattern | Shrirang | Issue fixed while deserializing * claim-check-pattern | Shrirang | removed unused import * claim-check-pattern | Shrirang | fixed refactoring * claim-chek-pattern | Shrirang | added lombok | fixed dependencies & test cases * Delete .DS_Store * claim-check-pattern | Shrirang | Fixed unrelated file * Update BookService.java * Update BookService.java * claim-check-pattern | Shrirang | Fixed unrelated files * claim-check-pattern | Shrirang | Fixed review comments * Update UsageCostProcessorFunction.java * Update ReadME.md * Rename ReadME.md to README.md * claim-check-pattern | Shrirang | Incorporated review comments. * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Updated readme file * Read me file updated | Added more description Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> Co-authored-by: Subhrodip Mohanta <hello@subho.xyz> Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
layout, title, folder, permalink, categories, tags
layout | title | folder | permalink | categories | tags | ||
---|---|---|---|---|---|---|---|
pattern | Claim Check Pattern | cloud-claim-check-pattern | /patterns/cloud-claim-check-pattern/ | Cloud |
|
Name
Also known as
Intent
- Reduce the load of data transfer through the Internet. Instead of sending actual data directly, just send the message reference.
- Improve data security. As only message reference is shared, no data is exposed to the Internet.
Explanation
Real-World Example
Suppose if you want to build a photo processing system. A photo processing system takes an image as input, processes it, and outputs a different set of images. Consider system has one persistent storage, one input component, ten processing components, messaging platform. Once a photo is given to the input component, it stores that image on persistent storage. It then creates ten different messages/events with the same image location and publishes them to the messaging platform. The messaging platform triggers ten different processing components. The ten processing components extract information about image location from the received event and then read an image from persistent storage. They generate ten different images from the original image and drop these images again to persistent storage.
In Plain words
Split a large message into a claim check and a payload. Send the claim check to the messaging platform and store the payload to an external service. This pattern allows large messages to be processed while protecting the message bus and the client from being overwhelmed or slowed down. This pattern also helps to reduce costs, as storage is usually cheaper than resource units used by the messaging platform.(ref)
Architecture Diagram
Applicability
Use the Claim Check Pattern when
- Huge processing data causes a lot of bandwidth consumption to transfer data through the Internet.
- To secure your data transfer by storing in common persistent storage.
- Using a cloud platform - Azure Functions or AWS Lambda, Azure EventGrid or AWS Event Bridge, Azure Blob Storage or AWS S3 Bucket.
- Each service must be independent and idempotent. Output data is dropped to persistent storage by the service.
- Publish-subscribe messaging pattern needs to be used.
Consequences
- This pattern is stateless. Any compute API will not store any data.
- You must have persistent storage and a reliable messaging platform.
Tutorials
Workflow
Suppose a telecom company wants to build call cost calculator system which generate the call cost daily. At the end of each day, details of the calls made by the consumers are stored somewhere. The call calculator system will read this data and generate call cost data for each user. Consumers will be billed using this generated data in case of postpaid service.
Producer class( UsageDetailPublisherFunction
Azure Function) will generate call usage details (here we are generating call data in producer class itself. In real world scenario, it will read from storage). UsageDetailPublisherFunction
creates a message. Message consists of message header and message body. Message header is basically an event grid event or claim or message reference. Message body contains actual data. UsageDetailPublisherFunction
sends a message header to Event Grid topic usage-detail
and drops an entire message to the blob storage. Event Grid then sent this message header to the UsageCostProcessorFunction
Azure function. It will read the entire message from blob storage with the help of the header, will calculate call cost and drop the result to the blob storage.
Class Diagrams
Setup
- Any operating system can be used macOS, Windows, Linux as everything is deployed on Azure.
- Install Java JDK 11 and set up Java environmental variables.
- Install Git.
- Install Visual Studio Code.
- Install Azure Functions extension to be able to deploy using Visual studio.
Storage Data
The data is stored in the Azure blob storage in the container callusageapp
. For every trigger, one GUID is created. Under the GUID folder
, 2 files will be created input.json
and output.json
.
Input.json
is dropped producer
azure function which contains call usage details. Output.json
contains call cost details which are dropped by the consumer
azure function.