è¯ãäžæ¥ïŒ Apache Kafkaã¯éåžžã«é«éãªåæ£ã¡ãã»ãŒãžãããŒã«ãŒã§ããä»æ¥ã¯ããããã調çãããã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ããã·ã³ãã«ãªãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ãå®è£ ããæ¹æ³ã説æããŸãã ããã§ãApache Kafkaãç¥ãããããè©ŠããŠã¿ããæ¹ã¯ãcatã«ããããã
æŠèŠéš
ã¯ããã«
ãã®è³æã¯ãApache Kafkaã®å®å šãªèª¬æã§ãããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã®æ§ç¯ã«é¢ãã埮åŠãªåé¡ã§ããããŸããã ç¥ã£ãŠããå¿ èŠãããã®ã¯ã.NETãã©ãããã©ãŒã ã§ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããæ¹æ³ã ãã§ãã .Net Core 2.0ã䜿çšããŸã
ã§ã¯ãæçµçã«ã¯äœãäœæããŸããïŒ ããªãã®åäŸã«ååãä»ããæ¹æ³ãæããŠãããã¢ããªã±ãŒã·ã§ã³ã ç°¡åã«ããããã«ãäºåå®çŸ©ãªã¹ãããã©ã³ãã ã«ç·æ§ãšå¥³æ§ã®ååãçºè¡ããŸãã ã·ã¹ãã ã¯ã2ã€ã®ã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ãš1ã€ã®ã©ã€ãã©ãªã§æ§æãããŸãã
ã¢ã€ãã¢ã¯ããã¢ããªã·ãã¯ãã§ã¯ãªããåæ£ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããããšã§ãã ãããã£ãŠãå°æ¥ã®ã¹ã±ãŒãªã³ã°ãã ããã§èª¬æããä»ã®å€ãã®å©ç¹ã®ããã«äºåã確ä¿ããŸãã
ã·ã¹ãã ã®æ§é ã¯æ¬¡ã®ãšããã§ãã
åŽé¢ã«ãã3ã€ã®éããé·æ¹åœ¢ãã¯ã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ã§ãã å®éã以äžã®2ã€ã¯ãã€ã¯ããµãŒãã¹ã§ãããMainAppã¯ãŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ã§ãããããéããŠãååãèŠæ±ããŸãã NameServiceã¯ãç·æ§ãŸãã¯å¥³æ§ã®ååãçæã§ãããŠãããŒãµã«ãµãŒãã¹ã«ãªããŸãã
äžå€®ã®ãªã¬ã³ãžè²ã®ãé·æ¹åœ¢ãã¯ãApache Kafkaã¡ãã»ãŒãžãããŒã«ãŒã§ãã ã¡ãã»ãŒãžãããŒã«ãŒã¯ãã·ã¹ãã ã®ãã¹ãŠã®éšåãæ¥ç¶ãããã®ã§ãã ä»åã®ã±ãŒã¹ã§ã¯ãApache Kafkaã䜿çšããŸãããåãæåãåããå ŽåãRabbitMQãActiveMQããŸãã¯ãã®ä»ã䜿çšã§ããŸãã
ãããŠããããMainAppãšApache Kafkaã®çžäºäœçšã§ãã
ããã¯æ¬¡ã®ããã«æ©èœããŸãã
- ãŠãŒã¶ãŒã¯ãããã€ãã®ããŒã¿ïŒãã®å Žåã¯ç·æ§ãŸãã¯å¥³æ§ã®ååïŒãèŠæ±ããŸãã
- MainAppã¯ãã¡ãã»ãŒãžïŒå³ã®ãããŒã ãïŒãApache Kafkaã«éä¿¡ããApache Kafkaã¯å¿ èŠãªãã¹ãŠã®ãµãŒãã¹ãèªåçã«åä¿¡ããŸãã
- ãããã®ãµãŒãã¹ã¯ãå¥ã®ã¡ãã»ãŒãžïŒå³ã®ããŒã¿ïŒãApache Kafkaã«éä¿¡ããããšã§å¿çããŸãã MainAppã¯ãå¿ èŠãªæ å ±ãå«ãApache KafkaïŒå³ã§ã¯ãããŒã¿ãïŒãããã®ã¡ãã»ãŒãžãåä¿¡ãããŠãŒã¶ãŒã«æäŸããŸãã
åãµãŒãã¹ãšApache Kafkaã®çžäºäœçšã¯ãåæ§ã®ãåæ¹åãã¹ããŒã ã«åŸã£ãŠçºçããŸãã
MainAppã¯NameServiceã«ã€ããŠäœãèªèããããã®éãåæ§ã§ããããšã«æ³šæããŠãã ããã ãã¹ãŠã®å¯Ÿè©±ã¯ãApache Kafkaãä»ããŠè¡ãããŸãã ãã ããMainAppãšNameServiceã®äž¡æ¹ã§åããéä¿¡ãã£ãã«ãã䜿çšããå¿ èŠããããŸãã å®éã«ã¯ãããã¯ãããšãã°ãMainAppãã¡ãã»ãŒãžãéä¿¡ãããããã¯ã®ååããNameServiceããªãã¹ã³ãããããã¯ã®ååãšå®å šã«äžèŽããå¿ èŠãããããšãæå³ããŸãã
ã芧ã®ãšããããã®äŸã®Apache Kafkaã®æ©èœã¯ãã·ã¹ãã ã®ç°ãªãèŠçŽ éã§ã¡ãã»ãŒãžã転éããããšã§ãã ããã圌女ã®ä»äºã§ãããéåžžã«è¿ éãã€ç¢ºå®ã§ãã ãã¡ããã圌女ã«ã¯ä»ã®å¯èœæ§ããããŸããå ¬åŒãŠã§ããµã€ãã§ãããã«ã€ããŠèªãããšãã§ããŸãã
Apache Kafkaãšã¯
Apache Kafkaã¯åæ£ã¡ãã»ãŒãžãããŒã«ãŒã§ãã å®éãããã¯ã¡ãã»ãŒãžãéåžžã«è¿ éãã€å¹ççã«è»¢éã§ããã·ã¹ãã ã§ãã Kafkaã®å Žåã¯åãªããã€ãã·ãŒã±ã³ã¹ã§ãããããã¡ãã»ãŒãžã¯ä»»æã®ã¿ã€ãã®ããŒã¿ã«ã§ããŸãã Apache Kafkaã¯ã1å°ã®ãã·ã³ãŸãã¯è€æ°ã®ãã·ã³ã®äž¡æ¹ã§åäœããã¯ã©ã¹ã¿ãŒã圢æããŠã·ã¹ãã å šäœã®å¹çãé«ããŸãã ãã®å ŽåãApache KafkaãããŒã«ã«ã§èµ·åããApache Kafkaãšã®å¯Ÿè©±ã«ã¯Confluentã®ã©ã€ãã©ãªã䜿çšããŸãã
Apache Kafkaã®ä»çµã¿ãç解ããããšã¯éèŠã§ãã ã¡ãã»ãŒãžãæžã蟌ãããšãã§ããããããèªã¿åãããšãã§ããŸãã Kafkaã®ãã¹ãŠã®ã¡ãã»ãŒãžã¯ããããããã¯ãŸãã¯å¥ã®ãããã¯ïŒãããã¯ïŒã«å±ããŸãã ãããã¯ã¯ã¿ã€ãã«ã®ãããªãã®ã§ãããApache Kafkaã«è»¢éããã¡ãã»ãŒãžããšã«å®çŸ©ããå¿ èŠããããŸãã åæ§ã«ãKafkaããã¡ãã»ãŒãžãèªãå Žåããããã®ã¡ãã»ãŒãžãã©ã®ãããã¯ã«å«ãŸããããæå®ããå¿ èŠããããŸãã
ãã®ãããã¯ã¯ã»ã¯ã·ã§ã³ã«åå²ãããŠãããååãšããŠãã®æ°ãç¬èªã«ç€ºããŠããŸãã ãããã¯å ã®ã»ã¯ã·ã§ã³ã®æ°ã¯ããã©ãŒãã³ã¹ã«ãšã£ãŠéåžžã«éèŠã§ããããã«ã€ããŠã¯ããã§èªãããšãã§ããŸã
å®çšéš
Apache Kafka 0.11ãããŠã³ããŒãããŠå®è¡ãã
çŸæç¹ã§ã¯ãææ°ããŒãžã§ã³ã¯ããŒãžã§ã³0.11ã§ãã å ¬åŒãµã€ãïŒhttps://kafka.apache.org/downloadsïŒããã¢ãŒã«ã€ããããŠã³ããŒãããä»»æã®ãã©ã«ããŒã«è§£åããŸãã ããã«ã³ã³ãœãŒã«ããã次ã®ããã«2ã€ã®ãã¡ã€ã«ïŒzookeeper-server.startããã³kafka-server-startïŒãå®è¡ããå¿ èŠããããŸãã
æåã®ã³ã³ãœãŒã«ãéãïŒãã©ã€ãCã«å±éããå Žåãäžãäžã«åããŠç®¡çè ã«ä»£ãã£ãŠéããŸãïŒãKafkaã§ã¢ãŒã«ã€ããå±éããå Žæã«ç§»åãã次ã®ã³ãã³ããå ¥åããŸãã
bin \ windows \ zookeeper-server-start.bat config \ zookeeper.properties
ãã®åŸããã¹ãŠãæ£åžžã§ããããã®ããã»ã¹ãéå§åŸããã«åæ¢ããªãã£ãå Žåã2çªç®ã®ã³ã³ãœãŒã«ãéããŠApache Kafkaèªäœãéå§ããŸã
bin \ windows \ kafka-server-start.bat config \ server.properties
zookeeper.propertiesãšserver.propertiesã§ããããæå®ãããããã©ã«ãèšå®ã§ZookeeperãšApache Kafkaãèµ·åããŸããã Zookeeperã¯å¿ èŠãªèŠçŽ ã§ãããããããªããšApache Kafkaã¯æ©èœããŸããã
Kafkaã®èµ·åãšèšå®ã«é¢ããå®å šãªæ å ±ã¯ã å ¬åŒWebãµã€ãã«ãããŸãã
ã³ãŒãã£ã³ã°ãéå§
ãã®ãããKafkaãèµ·åããŸããã次ã«ããåæ£ãã¢ããªã±ãŒã·ã§ã³ãäœæããŸãã 2ã€ã®ã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ãš1ã€ã®ã©ã€ãã©ãªã§æ§æãããŸãã ãã®çµæã次ã®ãããª3ã€ã®ãããžã§ã¯ãã®ãœãªã¥ãŒã·ã§ã³ãåŸãããŸãã
ç§ãã¡ã®ã©ã€ãã©ãªã¯Confluent.Kafkaã©ã€ãã©ãªã®ãã©ãããŒãã§ãããApache Kafkaãšå¯Ÿè©±ããããã«å¿ èŠã§ãã ããã«ãåã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšãããŸãã
ã©ã€ãã©ãªã¯ãã¿ãŒã²ãããã©ãããã©ãŒã ã察象ãšããŠããŸãNET Core 2.0ïŒãã ãããã©ãããã©ãŒã ã§ãåãæåãåããããšãã§ããŸããNETæšæºïŒãã®ã³ãŒãã以äžã«ç€ºããŸãã ãã®ããã«ã¯ãnugetããã±ãŒãžConfluent.KafkaãããŠã³ããŒãããå¿ èŠããããŸãã
MessageBus.cs
using System; using System.Collections.Generic; using System.Text; using System.Threading; using Confluent.Kafka; using Confluent.Kafka.Serialization; namespace MessageBroker.Kafka.Lib { public sealed class MessageBus : IDisposable { private readonly Producer<Null, string> _producer; private Consumer<Null, string> _consumer; private readonly IDictionary<string, object> _producerConfig; private readonly IDictionary<string, object> _consumerConfig; public MessageBus() : this("localhost") { } public MessageBus(string host) { _producerConfig = new Dictionary<string, object> { { "bootstrap.servers", host } }; _consumerConfig = new Dictionary<string, object> { { "group.id", "custom-group"}, { "bootstrap.servers", host } }; _producer = new Producer<Null, string>(_producerConfig, null, new StringSerializer(Encoding.UTF8)); } public void SendMessage(string topic, string message) { _producer.ProduceAsync(topic, null, message); } public void SubscribeOnTopic<T>(string topic, Action<T> action, CancellationToken cancellationToken) where T: class { var msgBus = new MessageBus(); using (msgBus._consumer = new Consumer<Null, string>(_consumerConfig, null, new StringDeserializer(Encoding.UTF8))) { msgBus._consumer.Assign(new List<TopicPartitionOffset> { new TopicPartitionOffset(topic, 0, -1) }); while (true) { if (cancellationToken.IsCancellationRequested) break; Message<Null, string> msg; if (msgBus._consumer.Consume(out msg, TimeSpan.FromMilliseconds(10))) { action(msg.Value as T); } } } } public void Dispose() { _producer?.Dispose(); _consumer?.Dispose(); } } }
ã©ã€ãã©ãªã³ãŒãã®èª¬æ
ã©ãããŒã¯ãApache Kafkaãšã®ãã¹ãŠã®å¯Ÿè©±ãç°¡çŽ åããã·ã¹ãã èŠçŽ å士ã®å¯Ÿè©±ã®ç¬éã«çŠç¹ãåœãŠãããã«äœæãããŸããã ã©ã€ãã©ãªã«ã¯ãSendMessageïŒïŒãšSubscribeOnTopicã®2ã€ã®ã¡ãœãããããããã¥ãŒããªã¢ã«ã®ãã¬ãŒã ã¯ãŒã¯å
ã«ã¯ãããããŸããã SubscribeOnTopicã§ãããããã¯ããµãã¹ã¯ã©ã€ãããã¡ãã»ãŒãžãç¶ç¶çã«ããªãã¹ã³ãããŸãããããã£ãŠãè€æ°ã®ãããã¯ããµãã¹ã¯ã©ã€ãããã«ã¯ãããããå¥ã
ã®ã¹ããªãŒã ã§å®è¡ããããšããå§ãããŸããããã¯ãåŸã§ãã®ã©ã€ãã©ãªã䜿çšããŠTask.RunïŒïŒæ§é ã䜿çšããŠè¡ããŸãã
次ã«ããã¡ã€ã³ãã¢ããªã±ãŒã·ã§ã³MainAppãäœæãã次ã«ããã€ã¯ããµãŒãã¹ãNameServiceãäœæããŸãã ãããã®ããããã¯ãç·æ§ãŸãã¯å¥³æ§ã®ååãçæãã責任ããããŸãã
.NET Core 2.0ã¿ãŒã²ãããã©ãããã©ãŒã çšã®MainAppã·ã³ãã«ã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ã³ãŒãã以äžã«ç€ºããŸãã ãã®äžã«ãå ã»ã©æ§ç¯ãããMessageBroker.Kafka.Libåå空éã«ããã©ã€ãã©ãªãžã®ãªã³ã¯ãè¿œå ããå¿ èŠãããããšã«æ³šæããŠãã ããã
MainApp.cs
using System; using System.Threading; using MessageBroker.Kafka.Lib; using System.Threading.Tasks; namespace MainApp { class Program { private static readonly string bTopicNameCmd= "b_name_command"; private static readonly string gTopicNameCmd = "g_name_command"; private static readonly string bMessageReq = "get_boy_name"; private static readonly string gMessageReq= "get_girl_name"; private static readonly string bTopicNameResp = "b_name_response"; private static readonly string gTopicNameResp= "g_name_response"; private static readonly string userHelpMsg = "MainApp: Enter 'b' for a boy or 'g' for a girl, 'q' to exit"; static void Main(string[] args) { using (var msgBus = new MessageBus()) { Task.Run(() => msgBus.SubscribeOnTopic<string>(bTopicNameResp, msg => GetBoyNameHandler(msg), CancellationToken.None)); Task.Run(() => msgBus.SubscribeOnTopic<string>(gTopicNameResp, msg => GetGirlNameHandler(msg), CancellationToken.None)); string userInput; do { Console.WriteLine(userHelpMsg); userInput = Console.ReadLine(); switch (userInput) { case "b": msgBus.SendMessage(topic: bTopicNameCmd, message: bMessageReq); break; case "g": msgBus.SendMessage(topic: gTopicNameCmd, message: gMessageReq); break; case "q": break; default: Console.WriteLine($"Unknown command. {userHelpMsg}"); break; } } while (userInput != "q"); } } public static void GetBoyNameHandler(string msg) { Console.WriteLine($"Boy name {msg} is recommended"); } public static void GetGirlNameHandler(string msg) { Console.WriteLine($"Girl name {msg} is recommended"); } } }
MainAppã³ãŒãã®ããã€ãã®èª¬æ
æåã«å€ãã®èªã¿åãå°çšæååå€æ°ãèŠãŸãããïŒ ãããã¯ããã¹ãŠã®ãããã¯ã®ååãšããããã«éä¿¡ããã¡ãã»ãŒãžã§ãã ã€ãŸããã¡ãã»ãŒãžã®ã¿ã€ãã«ãšããã¹ãã ãããã¯åãäžèŽããå¿
èŠããããããMainAppã察話ãããã¹ãŠã®ãµãŒãã¹ã¯ããããèªèããå¿
èŠããããŸãã ããšãã°ãbTopicNameCmdã¯ãç·æ§ã®ååãååŸããå¿
èŠããããµãŒãã¹ã³ãã³ãã®ãããã¯ã®ååã§ãïŒgTopicNameCmd-åæ§ïŒã ãµãŒãã¹ã¯ãåãååã®ãããã¯ãããµãã¹ã¯ã©ã€ãããŠãã¡ãã»ãŒãžãåä¿¡ããŠââããäœããå®è¡ããå¿
èŠããããŸãã
åæ§ã«ãMainAppã¯ãNameServiceãµãŒãã¹ãæçšãªæ å ±ã転éãããããã¯ã«ãµãã¹ã¯ã©ã€ããããŸãã ããšãã°ãå€æ°bTopicNameRespã¯ãããã¯ã®ååã§ãNameServiceãçæããæ¢è£œã®ç·æ§ã®ååã«æäŸãããŸãã ãµãŒãã¹ã¯ãã®ãããã¯ã«ååãéä¿¡ããMainAppã¯ããããããããåä¿¡ããŸãã
åæ§ã«ãMainAppã¯ãNameServiceãµãŒãã¹ãæçšãªæ å ±ã転éãããããã¯ã«ãµãã¹ã¯ã©ã€ããããŸãã ããšãã°ãå€æ°bTopicNameRespã¯ãããã¯ã®ååã§ãNameServiceãçæããæ¢è£œã®ç·æ§ã®ååã«æäŸãããŸãã ãµãŒãã¹ã¯ãã®ãããã¯ã«ååãéä¿¡ããMainAppã¯ããããããããåä¿¡ããŸãã
以äžã¯ãNameServiceã®ãã€ã¯ããµãŒãã¹ã³ãŒãã§ãã ããã§ããMessageBroker.Kafka.Libåå空éã§æ¢ã«äœæããã©ã€ãã©ãªãžã®ãªã³ã¯ãè¿œå ããå¿ èŠãããããšã«æ³šæããŠãã ãã
NameService.cs
using System; using System.Threading; using System.Threading.Tasks; using MessageBroker.Kafka.Lib; namespace NameService { class Program { private static MessageBus msgBus; private static readonly string userHelpMsg = "NameService.\nEnter 'b' or 'g' to process boy or girl names respectively"; private static readonly string bTopicNameCmd = "b_name_command"; private static readonly string gTopicNameCmd = "g_name_command"; private static readonly string bTopicNameResp = "b_name_response"; private static readonly string gTopicNameResp = "g_name_response"; private static readonly string[] _boyNames = { "Arsenii", "Igor", "Kostya", "Ivan", "Dmitrii", }; private static readonly string[] _girlNames = { "Nastya", "Lena", "Ksusha", "Katya", "Olga" }; static void Main(string[] args) { bool canceled = false; Console.CancelKeyPress += (_, e) => { e.Cancel = true; canceled = true; }; using (msgBus = new MessageBus()) { Console.WriteLine(userHelpMsg); HandleUserInput(Console.ReadLine()); while (!canceled) { } } } private static void HandleUserInput(string userInput) { switch (userInput) { case "b": Task.Run(() => msgBus.SubscribeOnTopic<string>(bTopicNameCmd, (msg) => BoyNameCommandListener(msg), CancellationToken.None)); Console.WriteLine("Processing boy names"); break; case "g": Task gTask = Task.Run(() => msgBus.SubscribeOnTopic<string>(gTopicNameCmd, (msg) => GirlNameCommandListener(msg), CancellationToken.None)); Console.WriteLine("Processing girl names"); break; default: Console.WriteLine($"Unknown command. {userHelpMsg}"); HandleUserInput(Console.ReadLine()); break; } } private static void BoyNameCommandListener(string msg) { var r = new Random().Next(0, 5); var randName = _boyNames[r]; msgBus.SendMessage(bTopicNameResp, randName); Console.WriteLine($"Sending {randName}"); } private static void GirlNameCommandListener(string msg) { var r = new Random().Next(0, 5); var randName = _girlNames[r]; msgBus.SendMessage(gTopicNameResp, randName); Console.WriteLine($"Sending {randName}"); } } }
NameServiceã³ãŒãã®èª¬æ
ãã®ãµãŒãã¹ã¯æ¬¡ã®ããã«æ©èœããŸãã
ã€ãã³ããã³ãã©ã¡ãœããã®æ¬æã§ã¯ãMainAppãæ¢ã«ãµãã¹ã¯ã©ã€ãããŠãããããã¯ã«ãæºåãã§ããååã®ã¡ãã»ãŒãžãéä¿¡ããŸãã ãããŠããã®ã€ãã³ãã¯ãMainAppãååãååŸããå¿ èŠããããšããã¡ãã»ãŒãžãéä¿¡ãããã³ã«çºçããŸãã
- æåã«ããµãŒãã¹ãç·æ§ã®ååãçæããã女æ§ã®ååãçæãããã決å®ããŸãïŒã€ãŸãããã®å Žåãæºåããããªã¹ãããã©ã³ãã ãªååãéžæããã ãã§ãïŒ
- 察å¿ãããããã¯ã賌èªãã
ã€ãã³ããã³ãã©ã¡ãœããã®æ¬æã§ã¯ãMainAppãæ¢ã«ãµãã¹ã¯ã©ã€ãããŠãããããã¯ã«ãæºåãã§ããååã®ã¡ãã»ãŒãžãéä¿¡ããŸãã ãããŠããã®ã€ãã³ãã¯ãMainAppãååãååŸããå¿ èŠããããšããã¡ãã»ãŒãžãéä¿¡ãããã³ã«çºçããŸãã
æã¡äžã
çè«çã«ã¯ããã®æ®µéã§ãå¿ èŠãªãã¹ãŠã®ã³ãŒããåããæ¢æã®ãœãªã¥ãŒã·ã§ã³ããã§ã«çšæãããŠããã¯ãã§ãã ãã®åŸã次ã®æäœãå®è¡ã§ããŸãã2ã€ã®ã¢ããªã±ãŒã·ã§ã³ïŒMainAppãšNameServiceïŒãããã«éå§ããããã«ãœãªã¥ãŒã·ã§ã³ãæ§æããããããéå§ããŸãïŒ Apache Kafkaãæ¢ã«å®è¡ãããŠããããšã確èªããŠãã ãã ïŒã NameServiceã«ãbããŸãã¯ãgããå ¥åããŠãç·æ§ãŸãã¯å¥³æ§ã®ååãçæããããã«ãµãŒãã¹ãæ§æããåãæ¹æ³ã§MainAppã®ãbããŸãã¯ãgããå ¥åããŸããããããã®åãååãååŸããŸãã 次ã«ãMainAppã§ååãååŸããŸãã
ãã®æ®µéã§ã¯ãæ§å¥ã¯1ã€ã ãã§ãã ç·æ§ã®ã¿ã ãšããŸãã ä»ãç§ãã¡ã¯å¥³æ§ã®ååãååŸãããã£ãã NameServiceãããžã§ã¯ããåéããããã©ã«ããŒã«ç§»åããã dotnet NameService.dll ã ã³ãã³ãã䜿çšããŠã³ã³ãœãŒã«ã§å¥ã®ãµãŒãã¹ãå®è¡ããŸãã
ãã®äžã«ãgãã³ãã³ããå ¥åããMainAppã§å¥³æ§ã®ååãèŠæ±ãããšããããååŸããŸãã
ã¡ãªã¿ã«ããã®æ¹æ³ã§å¥œããªã ãNameServiceãšã³ãã£ãã£ãå®è¡ã§ããŸããããã¯ããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã®å©ç¹ã®1ã€ã§ãã ããšãã°ããµãŒãã¹ã®1ã€ããèœã¡ããå Žåãã·ã¹ãã å šäœãã¯ã©ãã·ã¥ããããšã¯ãããŸããã ãŸã£ããåãä»äºãããä»ã®ãµãŒãã¹ããããŸãã
1ã€ã®ããšïŒããšãã°ãNameServiceã5åå®è¡ãããšã1ã€ã§ã¯ãªã5ã€ã®ååãMainAppã«éãããŸãã ããã¯ãserver.propertiesãã¡ã€ã«ã§æå®ãããApache Kafkaèšå®ãåå ã§ãã ãã¥ãŒããªã¢ã«ã®äžç°ãšããŠãè³æãè€éã«ããªãããã«ãæå³çã«ããã«è§ŠããŸããã
ãããã«
ãã®èšäºã§ã¯ããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ãã§ããã ãã·ã³ãã«ã§ã¢ã¯ã»ã¹ãããããã®ã«ããåçã説æããçããäŸã䜿çšããŠåæ£åApache Kafkaã¡ãã»ãŒãžãããŒã«ãŒã玹ä»ããŸããã ç§ã¯ãããããŸãããããšãæã¿ãèŠãŠãããŠããããšã:)