Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Config fallbackConfig = ConfigurationFactory.ParseString(@"
                    akka.suppress-json-serializer-warning=true
                    akka.loglevel = DEBUG
                ").WithFallback(ConfigurationFactory.FromResource <ConsumerSettings <object, object> >("Akka.Streams.Kafka.reference.conf"));

            var system = ActorSystem.Create("TestKafka", fallbackConfig);

            var throwEventActor = system.ActorOf(Props.Create <IntermediateMessageThrowEventActor>());

            var sequenceFlowInput = new SequenceFlowInput
            {
                ProcessInstanceId = Guid.NewGuid(),
                Payload           = new InputPayload
                {
                    Status  = "Exported",
                    EventId = Guid.NewGuid().ToString(),
                }
            };

            throwEventActor.Tell(sequenceFlowInput);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public async Task SendWithAkka(SequenceFlowInput inputMessage)
        {
            var producerSettings = ProducerSettings <Null, string> .Create(Context.System, null, null)
                                   .WithBootstrapServers(KafkaEndpoint);

            await Source
            .Single("Akka: " + inputMessage.ProcessInstanceId.ToString())
            .Select(kafkaMessage => ProducerMessage.Single(new ProducerRecord <Null, string>(TopicName, kafkaMessage)))
            .Via(KafkaProducer.FlexiFlow <Null, string, NotUsed>(producerSettings))
            .RunWith(Sink.Ignore <IResults <Null, string, NotUsed> >(), Materializer);
        }
Exemplo n.º 3
0
        public async Task Send(SequenceFlowInput inputMessage)
        {
            var config = new ProducerConfig {
                BootstrapServers = KafkaEndpoint
            };

            // If serializers are not specified, default serializers from
            // `Confluent.Kafka.Serializers` will be automatically used where
            // available. Note: by default strings are encoded as UTF8.
            using (var p = new ProducerBuilder <Null, string>(config).Build())
            {
                try
                {
                    await p.ProduceAsync("test", new Message <Null, string>
                    {
                        Value = "PLAIN: " + inputMessage.ProcessInstanceId.ToString()
                    });
                }
                catch (ProduceException <Null, string> e)
                {
                    Console.WriteLine($"Delivery failed: {e.Error.Reason}");
                }
            }
        }