Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ColourConsole.WriteLineYellow("Creating ReceiverActorSystem");
            ActorSystem system = ActorSystem.Create("ReceiverActorSystem");

            ColourConsole.WriteLineYellow("Creating DataReceiverActor");
            IActorRef receiver = system.ActorOf(Props.Create <DataReceiver>(), "DataReceiverActor");

            ActorMaterializer materializer = system.Materializer();

            using (system)
            {
                using (materializer)
                {
                    MeasurementsSinkReady ready = receiver.Ask <MeasurementsSinkReady>(new PrepareUpload(121)).Result;//, timeout: TimeSpan.FromSeconds(30)).Result;
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public async Task SinkRef_declared_inside_poco_must_be_serialized_properly()
        {
            var actor = Sys.ActorOf(Props.Create <DataSource>());

            var sink = Sink.ForEach <string>(str => {
                Output.WriteLine(str);
            });

            var sinkRef = await StreamRefs.SinkRef <string>()
                          .Throttle(1, TimeSpan.FromMilliseconds(100), 1, ThrottleMode.Shaping)
                          .To(sink)
                          .Run(Sys.Materializer());

            var message = new MeasurementsSinkReady(sinkRef);

            var serializer = Sys.Serialization.FindSerializerFor(message);

            byte[] serialized = null;
            serializer.Invoking(s => serialized = s.ToBinary(message)).ShouldNotThrow();
            object deserialized = null;

            serializer.Invoking(s => deserialized = s.FromBinary <MeasurementsSinkReady>(serialized)).ShouldNotThrow();
            deserialized.Should().BeOfType <MeasurementsSinkReady>();
        }