Ejemplo n.º 1
0
        public void Send(IEnvelope envelope)
        {
            if (envelope.Message == null)
            {
                envelope.Acknowledge();
                return;
            }

            var id = string.IsNullOrEmpty(
                envelope.CorrelationId)
                         ? (envelope.MessageId.GetHashCode() % 100).ToString()
                         : envelope.CorrelationId;

            Loop.Enqueue(() =>
            {
                SendToHandler(id, envelope);
            });
        }
Ejemplo n.º 2
0
        public void WireupDispatchers()
        {
            if (Dispatchers.Count == 0)
            {
                var dispatchers = Assimilate.GetAllInstancesOf <IDispatchMessage>();
                dispatchers
                .ForEach(x => x.Handles.ForEach(y => Dispatchers.AddOrUpdate(y, x, (t, m) => x)));
            }
            // prevent duplicate instantiations
            var agency = Assimilate.GetInstanceOf <IAgency>();

            agency.RegisterActorOf("", this);
            // prime director
            //Fibers.Send("", new Envelope<PrimeDirector>(new PrimeDirector()) { CorrelationId = "" });
            Loop.Enqueue(() => SendToHandler("", new Envelope <PrimeDirector>(new PrimeDirector())
            {
                CorrelationId = ""
            }));
            Signal.Wait(100);
        }