13/06/2022
DynamoDB Stream – Near-real time နဲ့ time-ordered sequence ဖြစ်တဲ့DynamoDB table ထဲက data modification events ကို capture ဖမ်းပေးတဲ့ feature ၁ခုပါ။
Stream record ထဲမှာ table name, event timestamp နဲ့ တခြား metadata တွေပါပါလိမ့်မယ်။ Delivery ကတော့ ၁ကြိမ်ထဲပို့ပေးမယ်လို့ guaranteed ပေးထားပြီးတော့ ၂၄နာရီကြာရင်တော့ stream record ထဲကနေ remove လုပ်သွားပါလိမ့်မယ်။
ဥပမာ - table ထဲကို new item ထဲ့လိုက်တဲ့ event ဖြစ်တဲ့အခါ, item ၁ခုလုံးနဲ့ attributes အာလုံးကို capture ဖမ်းပေးပါမယ်။
အကယ်၍ item က updated ဖြစ်သွားတဲ့အခါ, before နဲ့ after, modified attributes ကို capture ဖမ်းပါမယ်။
Item delted ဖြစ်သွားခဲ့ရင်, delete မလုပ်ခင် item ၁ခုလုံးကို capture လုပ်ပေးပါမယ်။
Lambda, Kinesis Client Library, API စတာတွေနဲ့အတူတူတွဲသုံးလို့ရပါတယ်။ ပုံမှာပြထားတဲ့အတိုင်း item အသစ်၁ခု table ထဲကိုထည့်လိုက်တဲ့အခါ, stream record အသစ်ရလာတဲ့အခါ event အနေနဲ့ lambda ကို trigger လုပ်ပါမယ်။ Lambda function က stream record ကိုဖတ်ပြီးတော့ SNS topic ကနေ messages ပို့ပေးပါမယ်။ SNS topic ကို subscribe လုပ်ထားတဲ့သူတွေဆီ notification ရပါလိမ့်မယ်။