﻿
{"id":27202,"date":"2024-10-12T13:44:28","date_gmt":"2024-10-12T13:44:28","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=27202"},"modified":"2024-10-12T13:44:28","modified_gmt":"2024-10-12T13:44:28","slug":"amazon-sns-asp-net-core-scalable-notification-system","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/amazon-sns-asp-net-core-scalable-notification-system\/","title":{"rendered":"Amazon SNS &#038; Asp.NET Core &#8211; Scalable Notification System"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Bu i\u00e7eri\u011fimizde web ve mobil uygulamalar\u0131nda notification sistemleri olu\u015fturmak isteyen geli\u015ftiriciler i\u00e7in Amazon taraf\u0131ndan sunulmu\u015f olan SNS(Simple Notification Service) servisini inceleyecek ve bir Asp.NET Core uygulamas\u0131nda nas\u0131l yap\u0131land\u0131r\u0131labilece\u011fini ve bir notification&#8217;\u0131n al\u0131nabilmesi i\u00e7in nas\u0131l subscribe olunabilece\u011fini vs. pratiksel olarak tecr\u00fcbe ediyor olaca\u011f\u0131z. O halde buyurun ba\u015flayal\u0131m&#8230;<\/p>\n<h3>Amazon SNS(Simple Notification Service) Nedir?<\/h3>\n<p>Amazon SNS, Amazon Web Services(AWS) taraf\u0131ndan sunulan cloud tabanl\u0131 ve olduk\u00e7a h\u0131zl\u0131, esnek, tamamen y\u00f6netilen bir mesaj yayma servisidir. SNS, pub-sub modelini kullanarak uygulamalar aras\u0131nda yahut uygulamalardan kullan\u0131c\u0131lara bildirim g\u00f6nderilmesini sa\u011flamakta ve bu niteli\u011finden dolay\u0131 \u00f6zellikle distributed sistemlerde ve microservice yap\u0131lanmalarda tercih edilmektedir.<\/p>\n<p>Amazon SNS; mobil cihazlar, e-posta, SMS, HTTPS endpoint&#8217;leri ve di\u011fer AWS servisleri gibi farkl\u0131 kanallara bildirim g\u00f6ndermek amac\u0131yla tercih edilmekte ve ayr\u0131ca sistem olaylar\u0131na yan\u0131t olarak otomatik bildirimler \u00fcretebilmektedir. Misal olarak bir uygulama hatas\u0131 meydana geldi\u011fi taktirde geli\u015ftiriciye uyar\u0131 g\u00f6nderebilmekte ve b\u00f6ylece \u00f6nemli durumlara kar\u015f\u0131n haz\u0131r k\u0131ta olunabilmesini ve anl\u0131k reaksiyon al\u0131nabilmesini sa\u011flamaktad\u0131r. T\u00fcm bunlar\u0131n d\u0131\u015f\u0131nda farkl\u0131 sistemler, diller veya teknolojiler aras\u0131nda h\u0131zl\u0131 ve g\u00fcvenilir mesajla\u015fma sa\u011flayabilmektedir.<\/p>\n<blockquote><p><em>SNS&#8217;in en \u00f6nemli \u00f6zelli\u011fi h\u0131zl\u0131 bir \u015fekilde \u00f6l\u00e7eklendirilebiliyor olmas\u0131d\u0131r.<\/em><\/p><\/blockquote>\n<p>Bizler Amazon SNS&#8217;i genellikle; kullan\u0131c\u0131lara uygulamada ger\u00e7ekle\u015fen \u00f6nemli olaylar i\u00e7in bildirim g\u00f6nderme maksatl\u0131 kullanmaktay\u0131z. Bunun d\u0131\u015f\u0131nda uygulamaya dair g\u00fcncellemeler, promosyonlar veya haberler hakk\u0131nda da bildirimler g\u00f6nderirken yahut uygulaman\u0131n veya sistem olaylar\u0131n\u0131n izlenme s\u00fcrecinde olas\u0131 kritik durumlara kar\u015f\u0131n notification verirken tercih etmekteyiz.<\/p>\n<p>K\u0131saca Amazon SNS; pub\/sub modelini uygulamakta, mesajlar\u0131 \u00e7e\u015fitli hedeflere y\u00f6nlendirebilmekte, IOS, Android ve di\u011fer platformlar i\u00e7in bildirimleri desteklemekte ve kulland\u0131k\u00e7a \u00f6de modeli ile maliyetlendirilmektedir.<\/p>\n<h3>Amazon SQS \u0130le SNS&#8217;in Farklar\u0131 Nelerdir?<\/h3>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/amazon-sqs-asp-net-core-scalable-messaging\/\" rel=\"noopener\" target=\"_blank\">Amazon SQS<\/a> ile SNS, farkl\u0131 kullan\u0131m senaryolar\u0131na y\u00f6nelik olarak tasarlanm\u0131\u015f olan AWS mesajla\u015fma servisleridirler. Temel farklar\u0131 ve kullan\u0131m senaryolar\u0131ndaki ayr\u0131\u015fmalar\u0131 a\u015fa\u011f\u0131daki tablo \u00fczerinden net bir \u015fekilde ortaya koyal\u0131m;<\/p>\n<table style=\"font-size:12px;\">\n<thead>\n<tr>\n<th width=\"20%\" style=\"text-align:left\">\u00d6zellik<\/th>\n<th width=\"40%\" style=\"text-align:left\">Amazon SNS<\/th>\n<th width=\"40%\" style=\"text-align:left\">Amazon SQS<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><strong>Mesajla\u015fma Modeli<\/strong><\/td>\n<td style=\"text-align:left\">Publish Subscribe<\/td>\n<td style=\"text-align:left\">Queue Based(Kuyruk Temelli)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Mesaj Da\u011f\u0131t\u0131m\u0131<\/strong><\/td>\n<td style=\"text-align:left\">Bir mesaj bir\u00e7ok aboneye da\u011f\u0131t\u0131lmaktad\u0131r.<\/td>\n<td style=\"text-align:left\">Bir mesaj yaln\u0131zca bir t\u00fcketici taraf\u0131ndan i\u015flenmektedir.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Kullan\u0131c\u0131lar<\/strong><\/td>\n<td style=\"text-align:left\">Abonelerdir(subscriber) ve birden fazla abone olabilir.<\/td>\n<td style=\"text-align:left\">T\u00fcketicilerdir(consumer) ve yaln\u0131zca bir tane olabilir. Kuyruk yahut mesaj t\u00fcketicisi de denebilir.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Teslimat Y\u00f6ntemi<\/strong><\/td>\n<td style=\"text-align:left\">Mesaj aboneye aktif olarak g\u00f6nderilir. <code>Push<\/code><\/td>\n<td style=\"text-align:left\">T\u00fcketici mesaj\u0131 kuyruktan iradesiyle \u00e7eker. <code>Pull<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Mesaj Y\u00f6nlendirme<\/strong><\/td>\n<td style=\"text-align:left\">HTTP(S), Lambda, SQS, e-posta, SMS<\/td>\n<td style=\"text-align:left\">Yaln\u0131zca kuyruktaki t\u00fcketicilere.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Kullan\u0131m Amac\u0131<\/strong><\/td>\n<td style=\"text-align:left\">Yay\u0131nlanan mesajlar\u0131n birden \u00e7ok hedefe bildirim mahiyetinde iletilmesidir.<\/td>\n<td style=\"text-align:left\">Bir kuyruk \u00fczerindeki mesajlar\u0131n s\u0131ral\u0131 bir \u015fekilde t\u00fcketici taraf\u0131ndan i\u015flenmesidir.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Mesaj S\u0131ras\u0131<\/strong><\/td>\n<td style=\"text-align:left\">FIFO(First-In-First-Out)<\/td>\n<td style=\"text-align:left\">FIFO(First-In-First-Out) ve Standart kuyruk se\u00e7enekleri mevcuttur.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Zaman A\u015f\u0131m\u0131 &#038; Saklama<\/strong><\/td>\n<td style=\"text-align:left\">Mesajlar anl\u0131k olarak iletilir. Saklanmazlar!<\/td>\n<td style=\"text-align:left\">Mesaj belirli bir s\u00fcre<span style=\"font-size:10px;\">(1dk ile 14 g\u00fcne kadar)<\/span> kuyrukta bekletilebilir.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Ba\u015fka AWS Servisleriyle Entegrasyon<\/strong><\/td>\n<td style=\"text-align:left\">Lambda, HTTP(S), e-posta, SMS, SQS ile entegrasyon m\u00fcmk\u00fcnd\u00fcr.<\/td>\n<td style=\"text-align:left\">Lambda ve di\u011fer t\u00fcketicilerle entegrasyon m\u00fcmk\u00fcnd\u00fcr.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Anlayaca\u011f\u0131n\u0131z; SNS, pub-sub modeliyle \u00e7al\u0131\u015fmakta ve bir olay ger\u00e7ekle\u015fti\u011finde mesaj yay\u0131nlayarak subscribe olan t\u00fcm uygulamalara g\u00f6ndermektedir. SQS ise kuyruk tabanl\u0131 bir mesajla\u015fma sistemidir ve mesajlar\u0131 s\u0131rayla kuyru\u011fa atarak ve bir t\u00fcketici taraf\u0131ndan bu mesajlar kuyruktan tek tek al\u0131narak i\u015flenmektedir. <\/p>\n<table style=\"font-size:12px;\">\n<thead>\n<tr>\n<th width=\"50%\">Amazon SNS \u00d6rnek Senaryo<\/th>\n<th width=\"50%\">Amazon SQS \u00d6rnek Senaryo<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\nE-ticaret uygulamas\u0131nda bir sipari\u015f verildi\u011finde, bu sipari\u015f bilgisi SNS ile yay\u0131mlanarak envanter y\u00f6netim sistemine, m\u00fc\u015fteriye ve ilgili di\u011fer departmanlara SMS ile bildirim g\u00f6nderir.\n<\/td>\n<td>Bir online video platformunda kullan\u0131c\u0131 bir video y\u00fckledi\u011finde, bu video i\u015flem kuyru\u011funa eklenir ve i\u015flemci s\u0131rayla her videoyu i\u015fleyip yay\u0131nlar. Y\u00fckleme talepleri h\u0131zl\u0131ca kuyrukta toplan\u0131rken, i\u015fleme i\u015flemi do\u011fal olarak daha yava\u015f bir h\u0131zda ilerleyecektir.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u0130\u015fte bu yap\u0131lar\u0131ndan dolay\u0131 SNS ve SQS s\u0131kl\u0131kla birlikte kullan\u0131lmakta ve esas\u0131nda davran\u0131\u015fsal a\u00e7\u0131dan birbirlerini tamamlayarak bir b\u00fct\u00fcn arz etmektedirler. SNS ile olaylar yay\u0131l\u0131rken, bu yayg\u0131n mesajlar\u0131n SQS kuyruklar\u0131na y\u00f6nlendirilerek bekletilebilmesi ve gerekti\u011finde s\u0131ral\u0131 bir \u015fekilde i\u015flenebilmesi m\u00fcmk\u00fcnd\u00fcr. Bunu \u015f\u00f6yle bir \u00f6rnek \u00fczerinden daha da somutla\u015ft\u0131rabiliriz; bir sipari\u015f verildi\u011finde SNS, hem muhasebe hem de envanter sistemine bir mesaj g\u00f6nderecektir. Diyelim ki, muhasebe sistemi i\u015flemi hemen\/an\u0131nda i\u015fleyebiliyor olsun amma velakin envanter sistemi a\u015f\u0131r\u0131 yo\u011fun oldu\u011fundan dolay\u0131 i\u015flenme s\u00fcrecinin yava\u015f ilerledi\u011fini d\u00fc\u015f\u00fcnelim. \u0130\u015fte bu durumda envanter sisteminde mesajlar\u0131 kuyru\u011fa atmam\u0131z ve yo\u011funlu\u011fa g\u00f6re i\u015flememiz gerekecektir. \u0130\u015fte tam da burada SNS ile SQS&#8217;in k\u00fcm\u00fclatif kullan\u0131lmas\u0131 gerecektir.<\/p>\n<p>Amazon SNS, bir olay ger\u00e7ekle\u015fti\u011finde yay\u0131nlayaca\u011f\u0131 mesaj\u0131 <a href=\"https:\/\/www.gencayyildiz.com\/blog\/rabbitmq-fanout-exchange\/\" rel=\"noopener\" target=\"_blank\">Fanout Exchange<\/a>&#8216;i kullanarak t\u00fcm subscriber&#8217;lara iletecektir. Haliyle bu bir push mekanizmas\u0131d\u0131r ve yeni mesajlar yay\u0131nlan\u0131r yay\u0131nlanmaz abonelere otomatik olarak iletilecektir. Oysa SQS pull tabanl\u0131 bir servistir ve bu da, mesajlar\u0131 i\u015flemeye haz\u0131r olduklar\u0131nda kuyruktan alacaklar\u0131 anlam\u0131na gelecektir. Yukar\u0131daki sat\u0131rlarda da ifade etmeye \u00e7al\u0131\u015ft\u0131\u011f\u0131m\u0131z \u00fczere SQS kuyruklar\u0131, bir t\u00fcketici taraf\u0131ndan i\u015flenene kadar mesajlar\u0131 depolamak i\u00e7in kullan\u0131lmaktad\u0131r. Lakin SNS&#8217;in tabiat\u0131 gere\u011fi mesaj depolama durumu s\u00f6z konusu de\u011fildir.<\/p>\n<blockquote><p><em>SNS realtime mesajla\u015fma i\u00e7in, SQS ise asenkron mesajla\u015fma i\u00e7in tasarlanm\u0131\u015ft\u0131r. O y\u00fczden mesaj teslimat\u0131 SNS&#8217;de an\u0131nda olmal\u0131yken, SQS&#8217;de ise gecikmeli olabilmektedir.<\/em><\/p><\/blockquote>\n<h3>Amazon SNS &#8211; Publisher-Subscriber Architecture<\/h3>\n<p>Distributed sistemlerde olduk\u00e7a \u00f6nemli bir ileti\u015fim modeli olan Publisher-Subscriber Architecture Amazon SNS&#8217;de a\u015fa\u011f\u0131daki diyagramda oldu\u011fu gibi i\u015flem ak\u0131\u015f\u0131na sahiptir;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.webp\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"2360\" height=\"1086\" class=\"aligncenter size-full wp-image-27211\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.webp 2360w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-300x138.webp 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1024x471.webp 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-768x353.webp 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1536x707.webp 1536w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2048x942.webp 2048w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-980x450.webp 980w\" sizes=\"auto, (max-width: 2360px) 100vw, 2360px\" \/><\/a>Burada g\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere publisher, mesaj\u0131, mesajlar\u0131 birden fazla aboneye yay\u0131nlamak i\u00e7in kullan\u0131lan ileti\u015fim arac\u0131 olan Amazon SNS&#8217;in topic&#8217;ine yay\u0131nlad\u0131\u011f\u0131nda, bu mesaj, pub-sub pattern&#8217;\u0131 davran\u0131\u015f\u0131yla t\u00fcm subscriber&#8217;lara g\u00f6nderilecektir. Tabi bu s\u00fcre\u00e7te diyagramdan da anla\u015f\u0131laca\u011f\u0131 \u00fczere mesajlar filtrelenebilmekte ve b\u00f6ylece belirli publisher&#8217;lar\u0131n mesajlar\u0131 subscriber&#8217;lara g\u00f6nderilebilmektedir. Ayr\u0131ca SNS, subscriber&#8217;lara ula\u015f\u0131lamamas\u0131 durumunda yeniden denemelerin nas\u0131l ele al\u0131naca\u011f\u0131n\u0131 tan\u0131mlayabilen teslimat protokollerini de(delivery protocols) desteklemektedir. Yap\u0131land\u0131r\u0131lan maksimum yeniden deneme e\u015fi\u011fi a\u015f\u0131ld\u0131\u011f\u0131 taktirde ise Amazon SNS mesaj\u0131 silecek ya da sonra yeniden deneme i\u00e7in <em style=\"color:red;\">Dead-letter queue (DLQ)<\/em> isimli kuyru\u011fa atacakt\u0131r. Evet, dead-letter queue ad\u0131ndan da anla\u015f\u0131laca\u011f\u0131 \u00fczere mesajlar\u0131n teslim edilemedi\u011fi durumlarda onlar\u0131 saklamak i\u00e7in kullan\u0131lan bir mekanizmad\u0131r. \u0130\u00e7eri\u011fimizin devam\u0131ndaki sat\u0131rlar\u0131nda SNS ile birlikte bu kuyru\u011fu da inceleyecek ve tecr\u00fcbe ediyor olaca\u011f\u0131z.<\/p>\n<h3>Amazon SNS Topic Olu\u015fturma<\/h3>\n<p>Evet, art\u0131k s\u0131ran\u0131n her zaman oldu\u011fu gibi pratiksel incelemeye geldi\u011fini s\u00f6yleyebiliriz. \u015eimdi ilk olarak AWS&#8217;de SNS servisine eri\u015felim ve bir topic&#8217;in nas\u0131l olu\u015fturuldu\u011funu inceleyelim. Bunun i\u00e7in Amazon Management Console \u00fczerinden a\u015fa\u011f\u0131daki gibi SNS servisini aramam\u0131z yeterli olacakt\u0131r.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.png\" alt=\"\" width=\"1045\" height=\"232\" class=\"aligncenter size-full wp-image-27214\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.png 1045w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-300x67.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1024x227.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-768x171.png 768w\" sizes=\"auto, (max-width: 1045px) 100vw, 1045px\" \/><\/a>Ard\u0131ndan a\u00e7\u0131lacak sayfada yan taraftaki &#8216;Create topic&#8217; k\u0131sm\u0131nda bir topic ad\u0131 belirleyelim ve &#8216;Next step&#8217; butonuna t\u0131klayal\u0131m.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"790\" height=\"333\" class=\"aligncenter size-full wp-image-27215\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1.png 790w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1-300x126.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1-768x324.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/a>Devam\u0131nda ise ilgili topic&#8217;in hangi tipte olu\u015fturulaca\u011f\u0131n\u0131 soracakt\u0131r;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Ekran-goruntusu-2024-10-07-225043.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Ekran-goruntusu-2024-10-07-225043.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"809\" height=\"545\" class=\"aligncenter size-full wp-image-27216\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Ekran-goruntusu-2024-10-07-225043.png 809w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Ekran-goruntusu-2024-10-07-225043-300x202.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Ekran-goruntusu-2024-10-07-225043-768x517.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/a>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere bu tipler \u00f6nceki i\u00e7eriklerimizden de a\u015fina oldu\u011fumuz FIFO ve Standard&#8217;d\u0131r. FIFO, saniyede 300&#8217;e kadar mesaj yay\u0131nlayabilen ve s\u0131ran\u0131n korunmas\u0131n\u0131 garanti eden bir tiptir ve yaln\u0131zca SQS protokol\u00fcn\u00fc desteklemektedir. Standard t\u00fcr\u00fc ise SQS, Lambda, E-Posta, HTTP vs. gibi birden fazla abonelik protokol\u00fcyle birlikte en y\u00fcksek yay\u0131nlama verimini sunmaktad\u0131r. Bizler Standard t\u00fcr\u00fcn\u00fc se\u00e7erek devam edelim.<\/p>\n<p>Sayfay\u0131 biraz a\u015fa\u011f\u0131ya indirdi\u011fimizde SNS&#8217;in topic mesajlar\u0131 i\u00e7in sa\u011flad\u0131\u011f\u0131 g\u00fcvenlik katman\u0131 olan &#8216;Encryption&#8217; yap\u0131land\u0131rmas\u0131n\u0131 g\u00f6receksiniz. Devam\u0131nda ise varsay\u0131lan de\u011ferleri koruyacak eri\u015fim politikalar\u0131na ya da veri g\u00fcvenli\u011fine dair ayarlar\u0131.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System.gif\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"800\" height=\"466\" class=\"aligncenter size-full wp-image-27217\" \/><\/a>Teslimat politikalar\u0131(delivery policy) sekmesine gelirseniz e\u011fer burada SNS&#8217;in ba\u015far\u0131s\u0131z durumlarda mesajlar\u0131 yeniden deneme ve yay\u0131nlama i\u00e7in varsay\u0131lan deneme say\u0131s\u0131n\u0131 yap\u0131land\u0131rabilmekteyiz. G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere ilk etapta default olarak 20 saniyelik gecikmeyle 3 yeniden deneme ger\u00e7ekle\u015ftirilmektedir. Bu de\u011ferleri a\u015fa\u011f\u0131daki g\u00f6rselde oldu\u011fu gibi de\u011fi\u015ftirebilme inisiyatifine sahibiz.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-1.gif\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"800\" height=\"629\" class=\"aligncenter size-full wp-image-27218\" \/><\/a>Velhas\u0131l, t\u00fcm bu teferruatlar\u0131 g\u00f6zden ge\u00e7irdikten sonra art\u0131k SNS topic&#8217;ini g\u00f6n\u00fcl rahatl\u0131\u011f\u0131yla olu\u015fturabiliriz.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1569\" height=\"604\" class=\"aligncenter size-full wp-image-27220\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2.png 1569w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2-300x115.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2-1024x394.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2-768x296.png 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2-1536x591.png 1536w\" sizes=\"auto, (max-width: 1569px) 100vw, 1569px\" \/><\/a><\/p>\n<h3>Asp.NET Core &#8211; SNS Topic&#8217;ine Mesaj Yay\u0131nlama(Publishing)<\/h3>\n<p>Evet, \u015fimdide olay\u0131 pratiksel olarak bir \u00f6rnek \u00fczerinden seyrediyor olaca\u011f\u0131z. Haliyle bir mesaj yay\u0131nc\u0131s\u0131 olarak hareket edecek ve subscriber&#8217;lara SNS mesajlar\u0131n\u0131 g\u00f6nderecek olan Asp.NET Core uygulamas\u0131 olu\u015fturaca\u011f\u0131z. Bunun i\u00e7in ilgili uygulamaya a\u015fa\u011f\u0131daki k\u00fct\u00fcphanelerin y\u00fcklenmesi gerekmektedir.<\/p>\n<p><code><a href=\"https:\/\/www.nuget.org\/packages\/AWSSDK.SimpleNotificationService\" rel=\"noopener\" target=\"_blank\">Install-Package AWSSDK.SimpleNotificationService<\/a><\/code><br \/>\n<code><a href=\"https:\/\/www.nuget.org\/packages\/awssdk.extensions.netcore.setup\/\" rel=\"noopener\" target=\"_blank\">Install-Package AWSSDK.Extensions.NETCore.Setup<\/a><\/code><\/p>\n<p>K\u00fct\u00fcphanelerin y\u00fcklenmesinin ard\u0131ndan uygulamaya a\u015fa\u011f\u0131daki gibi gerekli servisleri y\u00fckleyelim.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\n.\r\nbuilder.Services.AddDefaultAWSOptions(builder.Configuration.GetAWSOptions());\r\nbuilder.Services.AddAWSService&lt;IAmazonSimpleNotificationService&gt;();\r\n<\/pre>\n<\/div>\n<p>Burada opsiyonel bir \u015fekilde uygulaman\u0131n appsettings.json dosyas\u0131nda a\u015fa\u011f\u0131daki gibi profile ve region bilgilerini tan\u0131mlayabiliriz.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;AWS&quot;: {\r\n    &quot;Profile&quot;: &quot;default&quot;,\r\n    &quot;Region&quot;: &quot;ap-south-1&quot;\r\n  }\r\n<\/pre>\n<\/div>\n<p>Ben \u00f6nceki AWS i\u00e7eriklerimde oldu\u011fu gibi development makinemi AWS CLI Profile&#8217;\u0131n\u0131 kullanarak authentication yapacak \u015fekilde yap\u0131land\u0131rd\u0131\u011f\u0131m i\u00e7in bu k\u0131s\u0131mlar\u0131 es ge\u00e7iyorum.<\/p>\n<p>Evet, altyap\u0131y\u0131 kurdu\u011fumuza g\u00f6re art\u0131k notification mesaj\u0131m\u0131z\u0131 tasarlayabiliriz. Bunun i\u00e7in a\u015fa\u011f\u0131daki gibi bir \u00fcr\u00fcn\u00fcn olu\u015fturulmas\u0131n\u0131 abonelere duyuracak bir senaryo \u00fczerinde hareket edelim istiyorum ve bu minvalde &#8216;ProductCreatedNotification&#8217; s\u0131n\u0131f\u0131n\u0131 tasarl\u0131yorum.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public interface INotification\r\n    {\r\n    }\r\n<\/pre>\n<\/div>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public sealed record ProductCreatedNotification(int Id, string Name, string Description) : INotification\r\n    {\r\n    }\r\n<\/pre>\n<\/div>\n<p>Art\u0131k t\u00fcm temel kurulumu tamamlad\u0131\u011f\u0131m\u0131za g\u00f6re publisher&#8217;\u0131m\u0131z\u0131n bir mesaj\u0131 publish etmesini sa\u011flayacak endpoint&#8217;i olu\u015ftural\u0131m.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\n.\r\nvar app = builder.Build();\r\n\r\nconst string topicName = &quot;product-topic&quot;;\r\n\r\napp.MapPost(&quot;\/create-product&quot;, async (CreateProductRequest createProductRequest, IAmazonSimpleNotificationService snsService) =&gt;\r\n{\r\n    ProductCreatedNotification productCreatedNotification = new(\r\n        createProductRequest.Id,\r\n        createProductRequest.Name,\r\n        createProductRequest.Description);\r\n\r\n    \/\/Topic Arn, SNS Topic'inin benzersiz kimli\u011fine kar\u015f\u0131l\u0131k gelmektedir.\r\n    string topicArn = string.Empty;\r\n\r\n    \/\/Topic elde ediliyor.\r\n    Topic topic = await snsService.FindTopicAsync(topicName);\r\n\r\n    \/\/Topic var m\u0131 yok mu kontrol ediliyor.\r\n    if (topic is null)\r\n    {\r\n        \/\/Topic yoksa olu\u015fturuluyor.\r\n        CreateTopicResponse createTopicResponse = await snsService.CreateTopicAsync(topicName);\r\n\r\n        \/\/Olu\u015fturulan topic'in id'si elde ediliyor.\r\n        topicArn = createTopicResponse.TopicArn;\r\n    }\r\n    else\r\n        \/\/Topic varsa id'si elde ediliyor.\r\n        topicArn = topic.TopicArn;\r\n\r\n    \/\/Mesaj publish'i olu\u015fturuluyor.\r\n    PublishRequest publishRequest = new()\r\n    {\r\n        TopicArn = topicArn,\r\n        Message = JsonSerializer.Serialize(productCreatedNotification),\r\n        Subject = nameof(ProductCreatedNotification)\r\n    };\r\n\r\n    \/\/Mesaj publish ediliyor.\r\n    await snsService.PublishAsync(publishRequest);\r\n});\r\n.\r\n.\r\n.\r\n<\/pre>\n<\/div>\n<p>Yukar\u0131daki \u00e7al\u0131\u015fmaya g\u00f6z atarsan\u0131z e\u011fer <code>\/create-product<\/code> endpoint&#8217;ine gelen istek neticesinde &#8216;CreateProductRequest&#8217; i\u00e7erisindeki verilere kar\u015f\u0131l\u0131k bir \u00fcr\u00fcn\u00fcn olu\u015fturuldu\u011funu varsayarak Amazon SNS notification \u00e7al\u0131\u015fmas\u0131 ger\u00e7ekle\u015ftirmi\u015f bulunuyoruz. Burada dikkat edilmesi gereken husus, mesaj\u0131n yay\u0131nlanaca\u011f\u0131 topic&#8217;e dair kontroll\u00fc bir \u015fekilde davran\u0131\u015f\u0131n \u015fekillendirilmesidir. E\u011fer topic varsa id&#8217;sini al\u0131yoruz, yoksa da olu\u015fturup ard\u0131ndan id&#8217;sini elde ediyoruz. Burada bir topic&#8217;in id&#8217;sinden kastedilenin <code>TopicArn<\/code> oldu\u011fu a\u015fikar. Zaten \u00f6rnek kod blo\u011funda da gerekli a\u00e7\u0131klamay\u0131 yapt\u0131\u011f\u0131m\u0131z\u0131 g\u00f6r\u00fcyorsunuz. Evet, bizlerin Amazon SNS&#8217;de belirli bir topic \u00fczerinden mesaj yay\u0131nlayabilmesi i\u00e7in ilgili topic&#8217;in id&#8217;si olan <code>TopicArn<\/code> de\u011ferine ihtiyac\u0131m\u0131z vard\u0131r. Dolay\u0131s\u0131yla bu de\u011feri elde ettikten sonra mesaj\u0131m\u0131za kar\u015f\u0131l\u0131k gelen &#8216;ProductCreatedNotification&#8217; t\u00fcr\u00fcnden olu\u015fturulan instance&#8217;\u0131 serialize edip &#8216;PublishRequest&#8217; nesnesine <code>TopicArn<\/code> de\u011feri ile birlikte vererek mesaj\u0131 yay\u0131nl\u0131yoruz.<\/p>\n<p>\u015eimdi bu \u00e7al\u0131\u015fma neticesinde uygulamay\u0131 derleyip \u00e7al\u0131\u015ft\u0131ral\u0131m ve Postman \u00fczerinden a\u015fa\u011f\u0131daki test iste\u011finde bulunal\u0131m.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n{\r\n    &quot;id&quot;: 1,\r\n    &quot;name&quot;: &quot;Kitap&quot;,\r\n    &quot;description&quot;: &quot;Okumal\u0131k&quot;\r\n}\r\n<\/pre>\n<\/div>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"580\" height=\"287\" class=\"aligncenter size-full wp-image-27224\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3.png 580w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3-300x148.png 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a>Dikkat ederseniz yap\u0131lan iste\u011fin ba\u015far\u0131yla ger\u00e7ekle\u015ftirildi\u011fini g\u00f6r\u00fcyoruz. Lakin burada bilinmesi gereken, Amazon SNS&#8217;de topic olu\u015fturuldu\u011fu anda herhangi bir subscriber&#8217;\u0131 olmayaca\u011f\u0131d\u0131r ve bu durumda SNS topic&#8217;ine g\u00f6nderilen herhangi bir mesaj an\u0131nda siliniyor olacakt\u0131r. Velhas\u0131l, bizler kontrol ama\u00e7l\u0131 Amazon SNS servisi \u00fczerinden topic&#8217;lere g\u00f6z att\u0131\u011f\u0131m\u0131zda a\u015fa\u011f\u0131daki gibi ilgili topic&#8217;in olu\u015fturuldu\u011funu g\u00f6r\u00fcyor olaca\u011f\u0131z.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-4.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"564\" height=\"226\" class=\"aligncenter size-full wp-image-27225\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-4.png 564w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-4-300x120.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/a>Bu \u015fimdilik k\u00e2fidir. Gelin \u015fimdi t\u00fcrl\u00fc abonelikler \u00fczerinden Amazon SNS servisini incelemeye ba\u015flayal\u0131m.<\/p>\n<h4>E-Posta Aboneli\u011fi Tasarlayal\u0131m<\/h4>\n<p>Amazon SNS, yay\u0131nlanm\u0131\u015f olan mesajlar\u0131n bir kopyas\u0131n\u0131 bizlere mail olarak g\u00f6nderebilmektedir. Bunu deneyimlemek ve sistemin \u00e7al\u0131\u015f\u0131p \u00e7al\u0131\u015fmad\u0131\u011f\u0131n\u0131 test edebilmek i\u00e7in Gmail \u00fczerinden mevcut bir e-posta hesab\u0131n\u0131 kullanal\u0131m. Tabi bunun i\u00e7in \u00f6ncelikle Amazon SNS&#8217;in <em>Subscriptions<\/em> sekmesine gelip a\u015fa\u011f\u0131daki gibi olu\u015fturdu\u011fumuz &#8216;product-topic&#8217;i dinleyecek olan bir abone olu\u015ftural\u0131m.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1080\" height=\"522\" class=\"aligncenter size-full wp-image-27229\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5.png 1080w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5-300x145.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5-1024x495.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-5-768x371.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/a>G\u00f6rselden de anlayaca\u011f\u0131n\u0131z \u00fczere subscription eklendi\u011fi taktirde belirtilen mail&#8217;e bir onay maili g\u00f6nderilecektir.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1440\" height=\"418\" class=\"aligncenter size-full wp-image-27230\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6.png 1440w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6-300x87.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6-1024x297.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-6-768x223.png 768w\" sizes=\"auto, (max-width: 1440px) 100vw, 1440px\" \/><\/a>Bu gelen mail \u00fczerinden aboneli\u011fi onaylamak i\u00e7in &#8216;SubscribeURL&#8217; alan\u0131 kar\u015f\u0131s\u0131ndaki URL&#8217;e t\u0131klaman\u0131z(ya da kopyalay\u0131p taray\u0131c\u0131ya yap\u0131\u015ft\u0131rman\u0131z) yeterli olacakt\u0131r. Bu i\u015flem neticesinde a\u015fa\u011f\u0131daki g\u00f6rselde oldu\u011fu gibi taray\u0131c\u0131da bir XML \u00e7\u0131kt\u0131s\u0131yla kar\u015f\u0131la\u015f\u0131lacakt\u0131r;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-7.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"948\" height=\"206\" class=\"aligncenter size-full wp-image-27231\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-7.png 948w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-7-300x65.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-7-768x167.png 768w\" sizes=\"auto, (max-width: 948px) 100vw, 948px\" \/><\/a>Vee bir yandan da Amazon SNS servisine d\u00f6n\u00fcld\u00fc\u011f\u00fcnde de ilgili abonenin onayland\u0131\u011f\u0131 g\u00f6r\u00fclecektir.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-8.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"860\" height=\"230\" class=\"aligncenter size-full wp-image-27232\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-8.png 860w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-8-300x80.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-8-768x205.png 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/a>Evet, art\u0131k b\u00f6ylece Amazon SNS&#8217;de ki bir topic&#8217;e e-posta subscriber&#8217;\u0131 eklemi\u015f bulunmaktay\u0131z ve b\u00f6ylece ilgili topic&#8217;e her yeni mesaj yay\u0131nland\u0131\u011f\u0131nda bu e-posta&#8217;ya da mail olarak gidece\u011fini garanti etmi\u015f bulunuyoruz.<\/p>\n<p>Haliyle yukar\u0131daki sat\u0131rlarda Postman \u00fczerinden yap\u0131lan iste\u011fi tekrar yapal\u0131m ve abone olarak belirtilen e-posta&#8217;n\u0131n posta kutusunu g\u00f6zlemlemeye ba\u015flayal\u0131m. <span style=\"font-size:12px;\">(Beklenen mailler spam&#8217;e d\u00fc\u015febilir)<\/span><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1500\" height=\"363\" class=\"aligncenter size-full wp-image-27233\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9.png 1500w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9-300x73.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9-1024x248.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-9-768x186.png 768w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/a>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere Amazon SNS ile e-posta aboneli\u011fi olduk\u00e7a basit ve efektif bir \u015fekilde ger\u00e7ekle\u015ftirilebilmektedir.<\/p>\n<h4>Lambda Aboneli\u011fi Tasarlayal\u0131m<\/h4>\n<p>\u015eimdide AWS Lambda \u00fczerinden SNS topic&#8217;imize bir abonelik olu\u015ftural\u0131m. Tabi \u015fu ana kadar AWS Lambda&#8217;ya dair bir tecr\u00fcbeniz yoksa \u00f6ncelikle a\u015fa\u011f\u0131da referans edilen makaleleri okuman\u0131z\u0131 tavsiye ederim;<\/p>\n<ul style=\"font-size:12px;\">\n<li><a href=\"https:\/\/www.gencayyildiz.com\/blog\/net-7-aws-lambda-ile-serverless-computing\/\" rel=\"noopener\" target=\"_blank\">.NET 7 \u2013 AWS Lambda \u0130le Serverless Computing<\/a><\/li>\n<li><a href=\"https:\/\/www.gencayyildiz.com\/blog\/net-lambda-authorizer-ile-amazon-api-gatewayin-guvenligini-saglama\/\" rel=\"noopener\" target=\"_blank\">.NET \u2013 Lambda Authorizer \u0130le Amazon API Gateway\u2019in G\u00fcvenli\u011fini Sa\u011flama<\/a><\/li>\n<li><a href=\"https:\/\/www.gencayyildiz.com\/blog\/aws-lambda-ile-serverless-rest-api-gelistirme-asp-net-core-api\/\" rel=\"noopener\" target=\"_blank\">AWS Lambda \u0130le Serverless REST API Geli\u015ftirme (Asp.NET Core API)<\/a><\/li>\n<\/ul>\n<p>\u015eimdi Visual Studio \u00fczerinden a\u015fa\u011f\u0131daki gibi <em>Simple SNS Function<\/em> template&#8217;inde bir Lambda projesi olu\u015ftural\u0131m.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-10.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-10.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"663\" height=\"584\" class=\"aligncenter size-full wp-image-27234\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-10.png 663w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-10-300x264.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/a>Lambda i\u00e7eri\u011fine pek fazla m\u00fcdahale etmeksizin sadece log mesaj\u0131n\u0131 a\u015fa\u011f\u0131daki gibi de\u011fi\u015ftirmemiz yeterli olacakt\u0131r.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    private async Task ProcessRecordAsync(SNSEvent.SNSRecord record, ILambdaContext context)\r\n    {\r\n        context.Logger.LogInformation($&quot;Processed record Subject : {record.Sns.Message} | Message : {record.Sns.Message}&quot;);\r\n\r\n        \/\/ TODO: Do interesting work based on the new message\r\n        await Task.CompletedTask;\r\n    }\r\n<\/pre>\n<\/div>\n<p>Tabi AWS&#8217;de log demek <em>CloudWatch<\/em>&#8216;a kay\u0131t demektir. Haliyle buradaki tetiklenmeyi oradan takip edece\u011fiz. \u015eimdi olu\u015fturdu\u011fumuz bu Lambda&#8217;y\u0131 AWS&#8217;ye publish edelim.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-11.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"250\" height=\"216\" class=\"aligncenter size-full wp-image-27236\" \/><\/a><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-12.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-12.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"828\" height=\"544\" class=\"aligncenter size-full wp-image-27237\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-12.png 828w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-12-300x197.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-12-768x505.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/a><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-13.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-13.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"826\" height=\"547\" class=\"aligncenter size-full wp-image-27238\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-13.png 826w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-13-300x199.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-13-768x509.png 768w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/a>Burada ikinci ad\u0131mdaki t\u00fcm rollere eri\u015febilmek i\u00e7in ilgili kullan\u0131c\u0131n\u0131n permission&#8217;lar\u0131nda <code>AdministratorAccess<\/code>&#8216;in atand\u0131\u011f\u0131ndan emin olunmal\u0131d\u0131r. Ayr\u0131ca se\u00e7ilen rol\u00fcnde CloudWatch eri\u015fimi oldu\u011fundan da emin olunmal\u0131.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-14.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-14.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"827\" height=\"550\" class=\"aligncenter size-full wp-image-27239\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-14.png 827w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-14-300x200.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-14-768x511.png 768w\" sizes=\"auto, (max-width: 827px) 100vw, 827px\" \/><\/a>Evet, Lambda function&#8217;\u0131 publish ettikten sonra olu\u015fturulup olu\u015fturulmad\u0131\u011f\u0131n\u0131 AWS Lambda servisi \u00fczerinden a\u015fa\u011f\u0131daki gibi g\u00f6zlemleyebiliriz;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-15.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-15.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"459\" height=\"223\" class=\"aligncenter size-full wp-image-27240\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-15.png 459w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-15-300x146.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/a>Art\u0131k lambda&#8217;y\u0131 olu\u015fturdu\u011fumuza g\u00f6re SNS topic&#8217;e bu lambday\u0131 subscription olarak ekleyebiliriz. Bunun i\u00e7in a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnde oldu\u011fu gibi lambda function&#8217;a gelerek &#8216;Configuration&#8217; sekmesi \u00fczerinden &#8216;Triggers&#8217; kategorisine gelip &#8216;Add trigger&#8217; butonuna t\u0131klanmal\u0131 ve SNS servisinin olu\u015fturdu\u011fumuz topic&#8217;ine eklenmelidir.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-2.gif\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"800\" height=\"472\" class=\"aligncenter size-full wp-image-27241\" \/><\/a>Hatta bu i\u015flemden sonra SNS topic&#8217;ine gelerek Subscription&#8217;lara bakabilir ve a\u015fa\u011f\u0131daki gibi t\u00fcm listeyi g\u00f6rebilirsiniz;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-16.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-16.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"904\" height=\"211\" class=\"aligncenter size-full wp-image-27242\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-16.png 904w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-16-300x70.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-16-768x179.png 768w\" sizes=\"auto, (max-width: 904px) 100vw, 904px\" \/><\/a>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere SNS&#8217;e bir mesaj g\u00f6nderildi\u011finde hem e-posta at\u0131lacak hem de lambda \u00e7a\u011fr\u0131lacakt\u0131r. O halde hadi gelin test edelim&#8230;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-17.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-17.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"589\" height=\"330\" class=\"aligncenter size-full wp-image-27245\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-17.png 589w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-17-300x168.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a>G\u00f6rseldeki body&#8217;e sahip iste\u011fi yapt\u0131\u011f\u0131m\u0131z taktirde e-posta&#8217;n\u0131n yan\u0131nda CloudWatch&#8217;a da a\u015fa\u011f\u0131daki log&#8217;un at\u0131ld\u0131\u011f\u0131n\u0131 g\u00f6rece\u011fiz.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"680\" height=\"675\" class=\"aligncenter size-full wp-image-27246\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18.png 680w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18-300x298.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18-150x150.png 150w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-18-80x80.png 80w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a>\u0130\u015fte bu kadar \ud83d\ude42<\/p>\n<blockquote><p><em style=\"color:purple;\">Unutmay\u0131n! Lambda function \u00fczerinden CloudWatch&#8217;a bir log at\u0131labilmesi i\u00e7in &#8216;CloudWatchLambdaInsightsExecutionRolePolicy&#8217; ve &#8216;CloudWatchLogsFullAccess&#8217; rollerinin lambda&#8217;yla ili\u015fkilendirilmi\u015f olmas\u0131 gerekmektedir.<\/em><\/p><\/blockquote>\n<h3>Amazon SNS &#8211; Filter Policy<\/h3>\n<p>Amazon SNS&#8217;de yay\u0131nlanm\u0131\u015f olan mesajlar varsay\u0131lan olarak tan\u0131mlanm\u0131\u015f olan t\u00fcm subscriber&#8217;lara g\u00f6nderilecektir. Bizler istersek bu mesajlar\u0131 subscriber seviyesinde filtreleyebilir ve istedi\u011fimiz abonelerde istedi\u011fimiz mesajlar\u0131 elde edebiliriz. Bunun i\u00e7in olu\u015fturdu\u011fumuz SNS publisher servisimizin mesaj yay\u0131nlama kodunda a\u015fa\u011f\u0131daki gibi k\u00fc\u00e7\u00fck bir eklemenin yap\u0131lmas\u0131 yeterlidir.<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\n.\r\n    PublishRequest publishRequest = new()\r\n    {\r\n        TopicArn = topicArn,\r\n        Message = JsonSerializer.Serialize(productCreatedNotification),\r\n        Subject = nameof(ProductCreatedNotification)\r\n    };\r\n\r\n    #region SNS Filter Policy\r\n    publishRequest.MessageAttributes.Add(&quot;Scope&quot;, new MessageAttributeValue\r\n    {\r\n        DataType = &quot;String&quot;,\r\n        StringValue = &quot;Email&quot;\r\n    });\r\n    #endregion\r\n\r\n    await snsService.PublishAsync(publishRequest);\r\n.\r\n.\r\n.\r\n<\/pre>\n<\/div>\n<p>Dikkat ederseniz g\u00f6nderilecek mesaja dair esas\u0131nda bir scope belirlemekteyiz. Bu scope \u00fczerinden aboneleri ili\u015fkilendirerek gerekli mesaj filtrelemesini ger\u00e7ekle\u015ftirece\u011fiz. Yay\u0131nlanacak mesaj\u0131n hangi servise g\u00f6nderilece\u011fini belirleyebilmek i\u00e7in Amazon SNS topic&#8217;ine subscribe olmu\u015f olan servislerden istedi\u011finize a\u015fa\u011f\u0131daki gibi filter policy olarak eklemeniz yeterli olacakt\u0131r. Bunun i\u00e7in ekran g\u00f6r\u00fcnt\u00fcs\u00fcnde oldu\u011fu gibi SNS topic&#8217;i \u00fczerinden &#8216;Subscriptions&#8217; sekmesine ve oradan da ilgili subscriber&#8217;a t\u0131klanmal\u0131 ve a\u00e7\u0131lan sayfada &#8216;Subscription filter policy&#8217; kategorisindeki &#8216;Edit&#8217; butonuna t\u0131klayarak &#8216;Subscription filter policy&#8217; alan\u0131ndan istenilen mesaj filtrelemesi ger\u00e7ekle\u015ftirilmelidir.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-3.gif\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"800\" height=\"472\" class=\"aligncenter size-full wp-image-27247\" \/><\/a><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-19.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-19.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"576\" height=\"369\" class=\"aligncenter size-full wp-image-27248\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-19.png 576w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-19-300x192.png 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/a>Lambda function&#8217;a herhangi bir filtre koymad\u0131\u011f\u0131m\u0131z i\u00e7in herhangi bir scope&#8217;a sahip olan mesajlar lambda&#8217;ya g\u00f6nderilecekken, e-posta servisini filtreledi\u011fimiz i\u00e7in sadece &#8216;Email&#8217; scope&#8217;unu bar\u0131nd\u0131ran mesajlar e-posta olarak iletilecektir.<\/p>\n<h3>Retries<\/h3>\n<p>Amazon SNS, abonelere mesaj g\u00f6nderilmesinde bir sorun oldu\u011fu taktirde otomatik olarak yeniden deneyecektir. Hatta hat\u0131rlarsan\u0131z e\u011fer i\u00e7eri\u011fimizin ilk sat\u0131rlar\u0131nda teslimat politikalar\u0131(delivery policy)ndan bahsetmi\u015ftik. E\u011fer ki bir SNS topic&#8217;inin teslimat politikalar\u0131n\u0131 g\u00f6zlemlemek isterseniz buna ilgili topic&#8217;in a\u015fa\u011f\u0131daki g\u00f6rselde oldu\u011fu gibi &#8216;Delivery Policy (HTTP\/S)&#8217; sekmesinden eri\u015febilirsiniz.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-20.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-20.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"977\" height=\"777\" class=\"aligncenter size-full wp-image-27249\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-20.png 977w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-20-300x239.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-20-768x611.png 768w\" sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere burada 20 saniyelik aral\u0131klarla 3 kez yeniden deneme yap\u0131laca\u011f\u0131 yazmaktad\u0131r. E\u011fer ki bu denemeler neticesinde sorun ortadan kalkmazsa SNS mesaj\u0131 tutulmayacak ve kaybolacakt\u0131r. Yok mesajlar kaybolmas\u0131n istiyorsan\u0131z Dead Letter Queue(DLQ)&#8217;ya atman\u0131z gerekecektir.<\/p>\n<h3>Amazon SNS &#8211; Dead Letter Queues<\/h3>\n<p>Dead Letter Queues, Amazon SNS&#8217;de abonelere teslim edilemeyen mesajlar\u0131n tutulabilmesi i\u00e7in geli\u015ftirilmi\u015f bir <a href=\"https:\/\/www.gencayyildiz.com\/blog\/amazon-sqs-asp-net-core-scalable-messaging\/\" rel=\"noopener\" target=\"_blank\">SQS<\/a> kuyruk yap\u0131s\u0131d\u0131r. DLQ&#8217;nun kurulabilmesi i\u00e7in yap\u0131lmas\u0131 gereken Amazon SQS \u00fczerinden a\u015fa\u011f\u0131daki gibi bir kuyruk olu\u015fturmakt\u0131r.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-21.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-21.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"969\" height=\"516\" class=\"aligncenter size-full wp-image-27250\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-21.png 969w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-21-300x160.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-21-768x409.png 768w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/a>Bu kuyru\u011fu varsay\u0131lan de\u011ferleriyle olu\u015fturduktan sonra yap\u0131lmas\u0131 gereken, art\u0131k hangi abonede kullan\u0131lacaksa onda &#8216;Redrive policy (dead-letter queue)&#8217; olarak eklenmesidir. Misal olarak lambda subscriber&#8217;\u0131nda kullanacaksak a\u015fa\u011f\u0131daki gibi \u00e7al\u0131\u015fma yap\u0131lmas\u0131 gerekmektedir.<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-22.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-22.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"899\" height=\"731\" class=\"aligncenter size-full wp-image-27251\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-22.png 899w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-22-300x244.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-22-768x624.png 768w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/a><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1091\" height=\"513\" class=\"aligncenter size-full wp-image-27252\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23.png 1091w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23-300x141.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23-1024x481.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23-768x361.png 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23-520x245.png 520w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-23-720x340.png 720w\" sizes=\"auto, (max-width: 1091px) 100vw, 1091px\" \/><\/a>Tabi bu yap\u0131land\u0131rmada bulunduktan sonra \u015f\u00f6yle bir uyar\u0131yla kar\u015f\u0131la\u015fabilirsiniz;<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24.png\" alt=\"Amazon SNS &amp; Asp.NET Core - Scalable Notification System\" width=\"1450\" height=\"93\" class=\"aligncenter size-full wp-image-27253\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24.png 1450w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24-300x19.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24-1024x66.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2024\/10\/Amazon-SNS-Asp.NET-Core-Scalable-Notification-System-24-768x49.png 768w\" sizes=\"auto, (max-width: 1450px) 100vw, 1450px\" \/><\/a>Eee, AWS&#8217;nin yap\u0131s\u0131 gere\u011fi beklenildi\u011fi \u00fczere do\u011fal olarak iki farkl\u0131 servis olan SQS ile SNS aras\u0131nda do\u011frudan bir ili\u015fki olamaz. Haliyle SNS topic&#8217;inden SQS kuyruklar\u0131na bir mesaj iletimine izin verilmemektedir. Bu i\u015flemin ger\u00e7ekle\u015febilmesi i\u00e7in Amazon SNS topic&#8217;inin Amazon SQS kuyru\u011funa mesaj g\u00f6nderebilmesine izin vermemiz gerekecektir. Bunun i\u00e7in a\u015fa\u011f\u0131daki gibi bir Amazon SQS Queue politikas\u0131 olu\u015fturabiliriz;<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n.\r\n.\r\n.\r\n    {\r\n      &quot;Effect&quot;: &quot;Allow&quot;,\r\n      &quot;Principal&quot;: {\r\n        &quot;Service&quot;: &quot;sns.amazonaws.com&quot;\r\n      },\r\n      &quot;Action&quot;: &quot;sqs:SendMessage&quot;,\r\n      &quot;Resource&quot;: &quot;arn:aws:sqs:ap-south-1:905418427199:product-dead-letter-queue&quot;,\r\n      &quot;Condition&quot;: {\r\n        &quot;ArnEquals&quot;: {\r\n          &quot;aws:SourceArn&quot;: &quot;arn:aws:sns:ap-south-1:905418427199:product-topic&quot;\r\n        }\r\n     }\r\n.\r\n.\r\n.\r\n<\/pre>\n<\/div>\n<p>Ve bu politikay\u0131 ilgili kuyru\u011fu editleyerek &#8216;Access policy&#8217; k\u0131sm\u0131ndan a\u015fa\u011f\u0131daki gibi verebiliriz;<\/p>\n<div style=\"font-size:12px;\">\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;Version&quot;: &quot;2012-10-17&quot;,\r\n  &quot;Id&quot;: &quot;__default_policy_ID&quot;,\r\n  &quot;Statement&quot;: &#x5B;\r\n    {\r\n      &quot;Sid&quot;: &quot;__owner_statement&quot;,\r\n      &quot;Effect&quot;: &quot;Allow&quot;,\r\n      &quot;Principal&quot;: {\r\n        &quot;AWS&quot;: &quot;arn:aws:iam::905418427199:root&quot;\r\n      },\r\n      &quot;Action&quot;: &quot;SQS:*&quot;,\r\n      &quot;Resource&quot;: &quot;arn:aws:sqs:ap-south-1:905418427199:product-dead-letter-queue&quot;\r\n    },\r\n    {\r\n      &quot;Effect&quot;: &quot;Allow&quot;,\r\n      &quot;Principal&quot;: {\r\n        &quot;Service&quot;: &quot;sns.amazonaws.com&quot;\r\n      },\r\n      &quot;Action&quot;: &quot;sqs:SendMessage&quot;,\r\n      &quot;Resource&quot;: &quot;arn:aws:sqs:ap-south-1:905418427199:product-dead-letter-queue&quot;,\r\n      &quot;Condition&quot;: {\r\n        &quot;ArnEquals&quot;: {\r\n          &quot;aws:SourceArn&quot;: &quot;arn:aws:sns:ap-south-1:905418427199:product-topic&quot;\r\n        }\r\n     }\r\n    }\r\n  ]\r\n}\r\n<\/pre>\n<\/div>\n<p>Dikkat ederseniz ilk statement default olarak gelirken, ikincisi bizim olu\u015fturdu\u011fumuz politikaya kar\u015f\u0131l\u0131k gelmektedir. Art\u0131k SNS topic&#8217;inden lambda servisine mesaj g\u00f6nderme s\u00fcrecinde herhangi bir kusur meydana gelirse bu DLQ kuyru\u011funa g\u00f6nderilebilecektir.<\/p>\n<h5>Nihai Olarak&#8230;<\/h5>\n<p>\u00d6zellikle anl\u0131k haberle\u015fme sa\u011flayacak olan yaz\u0131l\u0131mlar i\u00e7in olduk\u00e7a kritik ve \u00f6nem arz eden Amazon SNS servisini olduk\u00e7a detayl\u0131 ve kapsaml\u0131 bir \u015fekilde incelemi\u015f ve k\u0131smen deneyimlemi\u015f bulunuyoruz. SQS ve SNS&#8217;e dair burada son kez vurgulanmas\u0131 gereken n\u00fcansa \u00f6zet mahiyetinde temas edip i\u00e7eri\u011fimizi noktalamak istiyorum.<\/p>\n<blockquote><p><em>Amazon SQS&#8217;de consomer kuyruktaki mesajlar\u0131 iradesiyle \u00e7ekerken, Amazon SNS&#8217;de subscriber&#8217;lara mesajlar direkt g\u00f6nderilir\/eri\u015ftirilir. \u0130\u015fte bundan dolay\u0131 Amazon SQS bir kuyruk yap\u0131s\u0131yken, Amazon SNS daha \u00e7ok bir an\u0131nda bildirim yap\u0131s\u0131(yani notification) sistemidir.<\/em><\/p><\/blockquote>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<p>Not : \u00d6rnek \u00e7al\u0131\u015fmaya a\u015fa\u011f\u0131daki github adresinden eri\u015febilirsiniz.<br \/>\n<a href=\"https:\/\/github.com\/gncyyldz\/AmazonSNS.Example\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/gncyyldz\/AmazonSNS.Example<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Bu i\u00e7eri\u011fimizde web ve mobil uygulamalar\u0131nda notification sistemleri olu\u015fturmak isteyen geli\u015ftiriciler i\u00e7in Amazon taraf\u0131ndan sunulmu\u015f olan SNS(Simple Notification Service) servisini inceleyecek ve bir Asp.NET Core uygulamas\u0131nda nas\u0131l yap\u0131land\u0131r\u0131labilece\u011fini ve bir notification&#8217;\u0131n al\u0131nabilmesi i\u00e7in&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":27254,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5155],"tags":[5158,5157,5090,4747,5106,5160,5107,5159,5156,5161],"class_list":["post-27202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-amazon-sns","tag-amazon-simple-notification-service","tag-amazon-sns","tag-amazon-sqs","tag-cloudwatch","tag-dead-letter-queue","tag-delivery-protocols","tag-dlq","tag-publisher-subscriber-architecture","tag-simple-notification-service","tag-simple-sns-function"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/27202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=27202"}],"version-history":[{"count":14,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/27202\/revisions"}],"predecessor-version":[{"id":27255,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/27202\/revisions\/27255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/27254"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=27202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=27202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=27202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}