Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:43
    cptjazz commented #3925
  • 11:40
    cptjazz synchronize #3925
  • 11:02
    valdisz edited #3904
  • 10:55
    Aaronontheweb synchronize #3926
  • 10:45
    Aaronontheweb opened #3927
  • 10:01
    valdisz synchronize #3904
  • 06:22
    cptjazz commented #3925
  • Sep 21 19:33
    Aaronontheweb opened #3926
  • Sep 21 16:19
    valdisz synchronize #3904
  • Sep 21 14:58
    Aaronontheweb synchronize #3924
  • Sep 21 14:58
    Aaronontheweb commented #3922
  • Sep 21 14:45
    valdisz synchronize #3904
  • Sep 21 14:43
    valdisz synchronize #3904
  • Sep 21 14:35
    Aaronontheweb commented #3925
  • Sep 21 09:51
    cptjazz opened #3925
  • Sep 21 09:11
    cptjazz opened #3924
  • Sep 20 23:30

    Aaronontheweb on dev

    added ability to support custom… (compare)

  • Sep 20 23:30
    Aaronontheweb closed #3923
  • Sep 20 23:30
    Aaronontheweb closed #3861
  • Sep 20 23:26
    Aaronontheweb opened #3923
Aaron Stannard
@Aaronontheweb
you can still use cluster.sharding for that
the actor can control its own life cycle
its just that the actor can be moved if a new node joins the cluster that can host shards
so it should be designed to behave like a persistent actor
where it has an explicit state recovery mechanism and processing stage it executes before it's allowed to process any new messages
vicosoft4real
@vicosoft4real
hmm
Aaron Stannard
@Aaronontheweb
you can pass in a Props class created using DI too
since the actors don't get deployed remotely
vicosoft4real
@vicosoft4real
please go along with me.
i have a shardenvilope :

public sealed class ShardEnvelope
{
public readonly string Recipient;
public readonly object Message;

    public ShardEnvelope(string recipient, object message)
    {
        Recipient = recipient;
        Message = message;
    }
}

}

an extrator : public class CustomMessageExtractor : HashCodeMessageExtractor
{
public CustomMessageExtractor(int maxNumberOfShards) : base(maxNumberOfShards) { }
public override string EntityId(object message) => (message as ShardEnvelope)?.Recipient;
public override object EntityMessage(object message) => (message as ShardEnvelope)?.Message ?? message;
// public string ShardId(object message)
// {
// return (message as ShardEnvelope)?.ShardId.ToString();
// }
}
message A :smile: public class Message1
{
public Message1(string name1)
{
Name1 = name1;
}
    public string Name1 { get; }
}
Actor A public class ActorA: AtLeastOnceDeliveryReceiveActor
{
    public override string PersistenceId { get; }
    readonly ILoggingAdapter _logger = Context.GetLogger();

    public ActorA()
    {
        PersistenceId = Uri.UnescapeDataString(Self.Path.Name);
        _logger.Info($"Instantiating {nameof(ActorA)} in the constructor with path {Self.Path}");
        Command<Message1>(msg =>
        {
            _logger.Info($"log message {msg.Name1}");
            IActorRef shardRegion2 = Context.System.BootstrapShard<ActorB>("web-node1");
            // Context.ActorOf(Props.Create<ActorB>());

        });
        //Command<Message2>(msg =>
        //{
        //    _logger.Info($"log message {msg.Name1}");

        //});
    }
}
public class ActorB : ReceivePersistentActor
{
    public override string PersistenceId { get; }
    readonly ILoggingAdapter _logger = Context.GetLogger();

    public ActorB()
    {
        PersistenceId = Uri.UnescapeDataString(Self.Path.Name);

        _logger.Info($"Instantiating {nameof(ActorB)} in the constructor with path {Self.Path.Name}");
        Command<Message2>(msg =>
        {
            _logger.Info($"log message {msg.Name1}");

        });

    }
}
at start up I configure my shardding as :smile: ClusterSharding sharding = ClusterSharding.Get(eduSaaSSystem);
IActorRef shardRegion = sharding.Start(
typeName: typeof(ActorA).Name,
entityProps: Props.Create<ActorA>(), // the Props used to create entities
settings: ClusterShardingSettings.Create(eduSaaSSystem)
.WithCoordinatorSingletonSettings(ClusterSingletonManagerSettings.Create(eduSaaSSystem))
.WithRole("web-node")
,
messageExtractor: new CustomMessageExtractor(100 * 10)
);
if i send message to shard region as shardRegion .Tell(new ShardEnvelope(id, messagea));
vicosoft4real
@vicosoft4real
@Aaronontheweb is it possible to send message to actorB with message2
@Aaronontheweb are u with me?
Aaron Stannard
@Aaronontheweb
I think so.... the message extractor is looking for a property called Recipient on the message
ah I see
you're using an envelope for that
but yeah, that message will be received by your persistent actor
vicosoft4real
@vicosoft4real
ok
Mitchell Tannenbaum
@naturallymitchell
How does Akka.net differ from Akka? (eg. architecturally, if it does)
Vagif Abilov
@object
@mitchtbaum Akka.NET is a port of Akka so it has the same architectural principles. The difference is in ecosystem, use of external libraries etc.
Mitchell Tannenbaum
@naturallymitchell
@object Thank you.
Vagif Abilov
@object
@mitchtbaum moreover, the port is rather accurate in use of terms, naming, configuration so it's possible to discuss Akka-related topics with developers of both communities.
jalchr
@jalchr
@Aaronontheweb thanks for detailed explanation and the valuable video.
I understand the complexity of the problem. I'll try to port this sample to akka.net and see how things go: http://proto.actor/blog/2017/06/24/money-transfer-saga.html
Jose Carlos Marquez
@oeaoaueaa
hi, is anyone available to review the pull request AkkaNetContrib/Akka.DI.Ninject#10 ?
jameswilddev
@jameswilddev
Hello! Does TestScheduler have any mechanism for emulating a failure to deliver the message sent by ScheduleTellOnceCancelable/etc?
Arjen Smits
@Danthar
@jameswilddev no, if you want to be sure its delivered (it will be send to the IActorRef you tell it to, but that actor might not receive it because its remote), you will have to use mechanisms like AtLeastOnceDelivery. So instead of directly sending it to the remote actor (assuming here) you put an atleastoncedelivery actor in between or something.
Or whatever other reliable delivery mechanism you want to use
So what im saying is: emulating a failure to deliver by the Scheduler, is the wrong place to be handling this.
jameswilddev
@jameswilddev
Ah, thanks. In this case, it is just sending a message to itself.
I guess I should mock out the scheduler itself, check that it sends that message, and then test that when the message is received (or not received) that it acts accordingly.
jameswilddev
@jameswilddev
Is it specified anywhere what the scheduler will do if I start a repeating tell and then the actor which started it crashes (or otherwise stops)? Will it just schedule messages until the node is restarted (it seems this is the case from my testing)?
Vagif Abilov
@object
Hello. I remember being recommended to put actor initialization logic in PreStart (such recommendation is also contained in Akka Bootcamp). What are the reasons for that except that before PreStart is called, an actor is not yet capable of receiving messages? For example, if an actor creates some child actors can the child creation logic be executed prior its PreStart? What can go wrong?
Aaron Stannard
@Aaronontheweb
@oeaoaueaa I'll take a look at it
Jose Carlos Marquez
@oeaoaueaa
thanks!
Aaron Stannard
@Aaronontheweb
left you a comment on there
just need to add multi-targeting back to the csproj file
Jose Carlos Marquez
@oeaoaueaa
thanks, I'll correct that now
mmansouri
@mmansouri
Hello all, newbie question , where to put hocon config when using asp net core thanks
Aaron Stannard
@Aaronontheweb
@mmansouri what I'm doing is putting the HOCON in its own text file
and then executing the following
/// <summary>
    ///     Used to load HOCON definitions from a dedicated HOCON file
    /// </summary>
    public static class HoconLoader
    {
        /// <summary>
        ///     Parses a HOCON <see cref="Config" /> object from an underlying file
        /// </summary>
        /// <param name="path">The path to the HOCON file.</param>
        /// <returns>A parsed <see cref="Config" /> object.</returns>
        public static Config FromFile(string path)
        {
            return ConfigurationFactory.ParseString(File.ReadAllText(path));
        }
    }
similar to how you'd use a .JSON file for Microsoft.Extensions.Configuration
and then I pass that hocon object into the ActorSystem.Create(string name, Config config) method
we'll probably add something to Akka.NET core to make that easier soon