Introduction of need of messaging system.


Introduction of need of messaging system.



Normally application වලදී request එකක් එනවා සහ  එම request එකට අදාලව  data process කරලා response එකක් දීම කරනු ලබනවා.මෙහිදී better user experience එකක් දෙන්න නම්  user ට ඉකමින් නිවැරදි response එකක් දීම අවශ්‍ය වෙනවා.එම නිසා response දෙන්න යන කාලය අඩුම කරගන්න වෙනවා. මේ සදහා data processing part එක ගැන අවධානය දෙන්න වෙනවා.Data processing part එකේදී යම් කොටසක් process වෙන්න සැලකියයුතු කාලයක් යනවනම් සහ එම කොටස individually execute කරගන්න විදිහට හදාගන්න පුලුවන්නම් (Non blocking, Asynchronous විදිහට) එම කොටස් asynchronous ලෙස background එකේ  run වීමට set කරලා response එක දීමට අදාළ ඉතුරු කොටස් process කරලා  response එක  දෙන්න ඕනේ(Example එකක් ලෙස order එකක් place  කරල  එය  process වෙද්දී ඒ order එකට අදාලව earn වෙන  loyalty points users ට order complete response එකත් එක්ක  ඒ වෙලාවේම කියන්න ඕනේ නැත්තම්, එම  points earn වෙන්න ඕනේ  logically part එක background එකේ  Asynchronous ලෙස  run කර ගත හැක). Asynchronous ලෙස  run කරන කොටස් ගෙන දැන් බලමු.

(when a request must trigger some heavy computation, but the response does not depend on it. Effectively allowing the server to handle other requests while the heavy computation runs independently on another thread)

Asynchronous ලෙස  run වෙන්න ඕනේ කොටස නිතර නිතර සිද්ද නොවන කොටසක් වෙන්න පුළුවන්.Example එකක් ලෙස අලුත්  product category එකක් admin හදලා active කරන විට log එකක් වදින්න ඕනේ යැයි සිතමු...product category නිතර නිතර හැදෙන්නේ නැති නිසා මෙය නිතර නිතර වෙන්නේ නැති වැඩක්.එවැනි අවස්ථාවල මෙම කොටස කෙලින්ම asynchounus code එකක් ලෙස run කර ගැනීමට හැක(මෙහිදී එම කොටස වෙනම thread එකකට දෙනවා කරගෙන යන්න.SpringBoot වලදී @Aync annotation එක use කරීමෙන්).නමුත් එසේ run වෙන්න ඕනේ කොටස ටිකක් වැඩිපුර වාරගණන් වෙනවනම් එසේ run වෙන්න ඕනේ කොටස් queue එකක් හැදෙන අතර  එක  temporally save කරලා තියාගෙන එකෙන් එක අරගෙන process කරවන ඕනේ backgroud එකේදී.මෙවැනි දේවල් event driven ලෙස  handle කරගත හැක.එනම් even එකක් හදල ඒවා queue එකකට දාලා එම event listen කරගෙන ඉන්න listeners ල event එකින්  එක  queue එකෙන් අරගෙන handle කරනවා.මෙය  one point to one point වෙන්නේ.එනම්  event එක  publish කරනවා එක කෙලින්ම එක්කෙනෙක් listen කරන් ඉදලා handle කරනවා.නමුත් ඒසේ ඇති වෙන event ප්‍රමාණය වැඩි වීමත් එක්ක මෙය application level එකේ handle කරන එක දෙයක් වෙන්නේ නෑ මොකද එය application එකේ අනෙක්  performance එකටත් බලපෙමක් වගේම application එක down කරලා නැවත app කරද්දී එහෙම එම event lost වෙලා තිබෙන්න පුළුවන් .එම event handle කරන්න thread හැදෙනවා.එසේ thread ඔක්කොම මේවට busy උනොත් එහෙම අනෙත් වැඩ කරගන්න වෙන්නේ නෑ  application එකට thread අඩු නිසා.ඒ වගේම  CPU RAM එහම වැඩිපුර event handle කරන්න use වෙනවනම්  application එකට අනෙත් process කරන්න hardware performance එක  උනත් මදි වෙනවා.එම නිසා මෙවැනි event, event management system(RabbitMQ, ActiveMQ Kafka වැනි) එකක් හරහා වෙනමම  handle කරන එක තමා කරන්න ඕනේ වෙන්නේ.[The first challenge is how to collect large volume of data and the second challenge is to analyze the collected data. To overcome those challenges, you must need a messaging system.]මෙහිදී event එක(message එක) messaging system එකකට දෙනවා. එහිදී queue එකක  එම message hold කරන් ඉදලා  listers ලට  බාර දෙනවා handle කරන්න.[A Messaging System is responsible for transferring data from one application to another, so the applications can focus on data, but not worry about how to share it. Distributed messaging is based on the concept of reliable message queuing. Messages are queued asynchronously between client applications and messaging system. Two types of messaging patterns are available − one is point to point and the other is publish-subscribe (pub-sub) messaging system. Most of the messaging patterns follow pub-sub.]

Comments

Popular posts from this blog

09.Data Binding.

Database - Topics

02. Spring – Creating spring project clone it with GIT step by step.