protected void Setup() { testTopic = "akka100"; subscription = Subscriptions.Topics(testTopic); probe = this.CreateTestProbe(); string configText = File.ReadAllText("akka.test.conf"); var config = ConfigurationFactory.ParseString(configText); var system_producer = ActorSystem.Create("TestKafka", config); materializer_producer = system_producer.Materializer(); var system_consumer = ActorSystem.Create("TestKafka", config); materializer_consumer = system_producer.Materializer(); this.Sys.Settings.Config.WithFallback(config); producerSettings = ProducerSettings <Null, string> .Create(system_producer, null, null) .WithBootstrapServers("kafka:9092"); consumerSettings = ConsumerSettings <Null, string> .Create(system_consumer, null, null) .WithBootstrapServers("kafka:9092") .WithGroupId("group1"); }
public void Start(ConsumerAkkaOption consumerActorOption) { IAutoSubscription makeshop_neworder = Subscriptions.Topics(consumerActorOption.Topics); var consumerSettings = ConsumerSettings <Null, string> .Create(consumerSystem, null, null) .WithBootstrapServers(consumerActorOption.BootstrapServers) .WithGroupId(consumerActorOption.KafkaGroupId); var materializer_consumer = consumerSystem.Materializer(); KafkaConsumer.CommittableSource(consumerSettings, makeshop_neworder) .RunForeach(result => { result.CommitableOffset.Commit(); Console.WriteLine($"Consumer: {result.Record.Partition}/{result.Record.Topic} {result.Record.Offset}: {result.Record.Value}"); if (consumerActorOption.RelayActor != null) { consumerActorOption.RelayActor.Tell(result.Record.Value); //ForgetAndFire 발송 } }, materializer_consumer); }