These are chat archives for akkadotnet/akka.net

21st
Apr 2016
Kris Schepers
@schepersk
Apr 21 2016 08:43
Hmm, if a name my sql server persistence plugin something else then "sql-server", it doesn't seem to work.. Anyone else having this problem?
Kris Schepers
@schepersk
Apr 21 2016 08:50
akka {
  persistence {
    journal {
      sql-server {
    class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
    plugin-dispatcher = "akka.actor.default-dispatcher"
    connection-string = "Data Source=(local);Initial Catalog=HelloClusterSharding;Integrated Security=SSPI"
    connection-timeout = 30s
    schema-name = Sharding
    table-name = EventJournal
    auto-initialize = on
    timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
    metadata-table-name = Metadata
      }
    }
  }
}
this works..
but when I replace the "sql-server" with something else, it doesn't..
Kris Schepers
@schepersk
Apr 21 2016 08:57

I'm trying to use a different sql server persistence for cluster sharding.
I have my sharding config set up like this:

cluster {
  sharding {
    least-shard-allocation-strategy.rebalance-threshold = 3
    journal-plugin-id = "akka.persistence.journal.sql-server"
    snapshot-plugin-id = "akka.persistence.snapshot-store.sql-server"
  }
}

but I would like to replace the "sql-server" name with, let's say "sql-server-sharding"

Damian Reeves
@DamianReeves
Apr 21 2016 12:24
If I'm starting a new green field project with Akka and F#, should I start with Akka.FSharp or should I go right to Akkling?
morioma
@morioma
Apr 21 2016 12:33

To handle remote disconnection I did something like this

signalRSelection = Context.ActorSelection("akka.tcp://api@127.0.0.1:4545/user/signalr");
signalRSelection.Tell(message);

So, I am forcing a Context.ActorSelection before tell. I am thinking this should work although there could be performance issue.
However, this doesn't seems to work all the time. (It works the first time the remote disconnected).
Anyway to do this kind of if(disconneted){ connect(); }?
(I am aware the watch for Terminated method. However, I have trouble finding the right time to ActorSelection again, because the remote could be still not available. )

Association to [akka.tcp://api@127.0.0.1:4545] having UID [221449129] is irrecoverably failed. UID is now quarantined and all messages to this UID will be delivered to dead letters. Remote actorsystem must be restarted to recover from this situation.
It seems that the remote server is quarantined, is there a way to prevent the remote server being quarantined?

Bartosz Sypytkowski
@Horusiath
Apr 21 2016 18:35
@schepersk currently journals are identified internally by their type - the workaround here is to create custom journal (i.e. inheriting from Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer) and replace it's type as a class name for configuration section used by cluster sharding
Boban
@bobanco
Apr 21 2016 19:03

@morioma i would use the actor selection to get the remote actor ref once on example on Actor.PreStart() and watch for the termination of the remote actor, when the remote actor dies, you can introduce a behavior like Reconnecting/ Registering and schedule the reconnect within some interval like 5secs on example.

here is some code which comes out of my mind now:

        protected override void PreStart()
        {

            Context.Become(Registering());
            Self.Tell(new LookupForServiceProvider());//LookupForService provider is just a simple message to tell yourself to start the actor selection

        }

private UntypedReceive Registering()
        {
            return message =>
            {
                if (message is RegisteredToServiceProvider)
                {
                          var registered = (RegisteredToServiceProvider) message;
                    Console.WriteLine("Registered to the service provider, Path: {0}",registered.ServiceProviderRef.Path);

                     //do some useful things here, mb switch to a different behavior where you can operate normaly
                      Context.Watch(registered.ServiceProviderRef);
                    Context.Become(Registered(registered.ServiceProviderRef));
                 }
                  else if (message is UnableToRegister)
                {
                    // we are not able to connect now, try reconnect within some time, and also stay into the same behavior.
                    Context.System.Scheduler.ScheduleTellOnce(_lookupTimeout,Self, new LookupForServiceProvider(), Self);
                }
                 else if (message is LookupForServiceProvider)
                {
                    var self = Context.Self;
                    try
                    {
                        Context.ActorSelection(sericeProviderPath)
                            .ResolveOne(_lookupTimeout)
                            .ContinueWith<IServiceLookupResult>(x =>
                            {
                                try
                                {
                                    var serviceProvider = x.Result;
                                    return new RegisteredToServiceProvider(serviceProvider);

                                }
                                catch (AggregateException ex)
                                {
                                    return new UnableToRegister();
                                }
                            }).PipeTo(self);
                    }
                    catch (Exception)
                    {
                        Self.Tell(new UnableToRegister());
                    }
                }
        }
}

private UntypedReceive Registered(IActorRef serviceProvider)
        {
            return message =>
            {
                  if (message is Terminated)
                {
                    var terminated = (Terminated)message;
                    if (terminated.ActorRef.Equals(serviceProvider))
                    {

                        Context.Become(Registering());
                        Self.Tell(new LookupForServiceProvider());
                        Console.WriteLine("Message Service provider is down, auto reconnect in {0} secs.", _lookupTimeout.TotalSeconds);
                    }
               }
sorry for bad formatting, but i wrote the code directly here, hope this will help you
morioma
@morioma
Apr 21 2016 21:02
@bobanco Thank you the method and the code. I will try it out :+1: