Exemplo n.º 1
0
        /// <summary>
        /// The run method
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        public void Run(Configure config)
        {
            Logger.Info("Statup.Run()");

            var initMessage = new MyMessage
            {
                SomeId    = "carlos",
                LargeBlob = new DataBusProperty <byte[]>(Guid.NewGuid().ToByteArray())
            };
            var anotherMessage = new AnotherSagaCommand {
                SomeId = initMessage.SomeId, SleepHowLong = 2000
            };

            Thread.Sleep(5000);
            this.bus.Send(initMessage);

            Thread.Sleep(1000);

            for (var i = 0; i < 5; i++)
            {
                anotherMessage.SleepHowLong = i;
                this.bus.SendLocal(anotherMessage);
            }

            anotherMessage.SleepHowLong = 0;
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
        }
        public Task Start(IMessageSession session)
        {
            Logger.Info("Statup.Start()");

            Logger.Info("Sending first message");
            var initMessage = new MyMessage
            {
                SomeId = Guid.NewGuid().ToString(),
                ////LargeBlob = new DataBusProperty<byte[]>(Guid.NewGuid().ToByteArray())
                LargeBlob = "Sandoval"
            };

            session.Send(initMessage).ConfigureAwait(false);

            Task.Delay(10000).Wait();

            Logger.Info("Sending other messages");
            var anotherMessage = new AnotherSagaCommand {
                SomeId = initMessage.SomeId, SleepHowLong = 1000
            };

            for (var i = 0; i < 5; i++)
            {
                anotherMessage.SleepHowLong = i;
                session.Send(anotherMessage).ConfigureAwait(false);
            }

            anotherMessage.SleepHowLong = 0;
            session.Send(anotherMessage).ConfigureAwait(false);
            session.Send(anotherMessage).ConfigureAwait(false);
            session.Send(anotherMessage).ConfigureAwait(false);

            return(Task.FromResult(0));
        }
Exemplo n.º 3
0
        public Task Handle(AnotherSagaCommand message, IMessageHandlerContext context)
        {
            this.Data.Count += 1;
            Logger.InfoFormat("Hello from AnotherSagaCommand: {0}", this.Data.Count);

            return(Task.FromResult(0));
        }
Exemplo n.º 4
0
        /// <summary>
        /// The run method
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        public void Run(Configure config)
        {
            Logger.Info("Statup.Run()");

            var initMessage = new MyMessage
                                  {
                                      SomeId = "carlos",
                                      LargeBlob = new DataBusProperty<byte[]>(Guid.NewGuid().ToByteArray())
                                  };
            var anotherMessage = new AnotherSagaCommand { SomeId = initMessage.SomeId, SleepHowLong = 2000 };

            Thread.Sleep(5000);
            this.bus.Send(initMessage);

            Thread.Sleep(1000);

            for (var i = 0; i < 5; i++)
            {
                anotherMessage.SleepHowLong = i;
                this.bus.SendLocal(anotherMessage);
            }

            anotherMessage.SleepHowLong = 0;
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
        }
Exemplo n.º 5
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 public void Handle(AnotherSagaCommand message)
 {
     this.Data.Count += 1;
     Logger.InfoFormat("Hello from AnotherSagaCommand: {0}", this.Data.Count);
 }