コード例 #1
0
        public void Notify(NotificationMessage notificationMessage)
        {
            var notificationId = ++_lastNotificationId;

            if (notificationId <= 0)
            {
                notificationId = _lastNotificationId = 1;
            }

            notificationMessage.NotificationId = notificationId;

            var sender = ActorCell.GetCurrentSelfOrNoSender();

            Receiver.Tell(notificationMessage, sender);
        }
コード例 #2
0
        public void Durable_CRDT_should_be_durable_after_gossip_update()
        {
            var r = NewReplicator();

            RunOn(() =>
            {
                Log.Debug("sending message with sender: {}", ActorCell.GetCurrentSelfOrNoSender());
                r.Tell(Dsl.Update(_keyC, ORSet <string> .Empty, WriteLocal.Instance, c => c.Add(_cluster, Myself.Name)));
                ExpectMsg(new UpdateSuccess(_keyC, null));
            }, _first);

            RunOn(() =>
            {
                r.Tell(Dsl.Subscribe(_keyC, TestActor));
                ExpectMsg <Changed>().Get(_keyC).Elements.ShouldBe(ImmutableHashSet.Create(_first.Name));

                // must do one more roundtrip to be sure that it keyB is stored, since Changed might have
                // been sent out before storage
                TellUpdate(r, _keyA, WriteLocal.Instance, new PocoObject("Id_1", 3));
                ExpectMsg(new UpdateSuccess(_keyA, null));

                Watch(r);
                Sys.Stop(r);
                ExpectTerminated(r);

                var r2 = default(IActorRef);
                AwaitAssert(() => r2 = NewReplicator()); // try until name is free
                AwaitAssert(() =>
                {
                    r2.Tell(Dsl.GetKeyIds);
                    ExpectMsg <GetKeysIdsResult>().Keys.ShouldNotBe(ImmutableHashSet <string> .Empty);
                });

                r2.Tell(Dsl.Get(_keyC, ReadLocal.Instance));
                ExpectMsg <GetSuccess>().Get(_keyC).Elements.ShouldBe(ImmutableHashSet.Create(_first.Name));
            }, _second);

            EnterBarrierAfterTestStep();
        }
コード例 #3
0
 public void Tell(T message)
 {
     Self.Tell(message, ActorCell.GetCurrentSelfOrNoSender());
 }
コード例 #4
0
        void IRequestWaiter.SendRequest(IRequestTarget target, RequestMessage requestMessage)
        {
            var sender = ActorCell.GetCurrentSelfOrNoSender();

            ((AkkaReceiverTarget)target).Receiver.Tell(requestMessage, sender);
        }
コード例 #5
0
 public static CommandQuery FromEventSource <TData>(this CommandQueryBuilder builder, IEventSource <TData> source, Func <TData, bool> check)
     where TData : class
 => builder.FromExternal <TData>(d => d != null && check(d), action => source.RespondOn(ActorCell.GetCurrentSelfOrNoSender() ?? ActorRefs.Nobody, action));
コード例 #6
0
 public static CommandQuery FromEventSource <TData>(this CommandQueryBuilder builder, IEventSource <TData> source, Func <TData, bool> check, TData defaultValue)
 => builder.FromExternal(check, action => source.RespondOn(ActorCell.GetCurrentSelfOrNoSender() ?? ActorRefs.Nobody, action), defaultValue);
コード例 #7
0
 public void Tell(TMessage message) => Ref.Tell(message, ActorCell.GetCurrentSelfOrNoSender());