F # Akkling не удается отправить сообщение через разделяющий прокси

#f# #akka.net

#f# #akka.net

Вопрос:

Когда я пытаюсь отправить сообщение на akka.прокси-сервер сетевого региона со следующим кодом,

 open Akkling.Cluster.Sharding
open Akka.Actor
open Akka.Cluster
open Akka.Cluster.Sharding
open System
open Akkling

let configWithPort (port:int) =
    let config = Configuration.parse ("""
        akka {
          actor {
            provider = cluster
          }
          remote {
            dot-netty.tcp {
              public-hostname = "localhost"
              hostname = "localhost"
              port = """   port.ToString()   """
            }
          }
          cluster {
            roles = ["Worker"]
            sharding {
                journal-plugin-id = "akka.persistence.journal.inmem"
                snapshot-plugin-id = "akka.persistence.snapshot-store.inmem"
            }
            seed-nodes = [ "akka.tcp://cluster-system@localhost:5000" ]
          }
        }
        """)
    config
      .WithFallback(Akka.Cluster.Tools.Singleton.ClusterSingletonManager.DefaultConfig())
      .WithFallback(ClusterSharding.DefaultConfig())

let system1 = ActorSystem.Create("cluster-system", configWithPort 5000)
let system2 = ActorSystem.Create("cluster-system", configWithPort 5001)

/// Domain
type FileCommand = {
    ProgramId : string
    Duration : TimeSpan
    FilePath : string
}

/// Actors
let aggregateRootActor (mailbox:Actor<_>) (msg:FileCommand) =
    let nodeAddress = Cluster.Get(mailbox.System).SelfUniqueAddress
    logInfof mailbox "Program: [%s] with path [%s] on [%A]" msg.ProgramId msg.FilePath nodeAddress
    ignored ()

let extractorFunction (message:FileCommand) =
    let entityId = message.ProgramId
    let hash = entityId.GetHashCode()
    let numberOfShards = 5
    let shardId = sprintf "shard_%d" ((abs hash) % numberOfShards)
    shardId, entityId, message

let region1 = spawnSharded extractorFunction system1 "fileRouter" (props (actorOf2 aggregateRootActor))
let region2 = spawnSharded extractorFunction system2 "fileRouter" (props (actorOf2 aggregateRootActor))

let shardRegionProxy = 
    spawnShardedProxy extractorFunction system1 "fileRouterProxy" None
  

И отправка сообщения на прокси-сервер всегда завершалась неудачей.

 shardRegionProxy <! { ProgramId = "a"; Duration = TimeSpan.FromMinutes 10.; FilePath = "\a_1.mp4" } //this failed
  

Сообщение об ошибке

 > [INFO][8/26/2020 5:13:15 PM][Thread 0027][akka://cluster-system/system/sharding/fileRouterProxyCoordinator/singleton/coordinator] Message [RegisterProxy] from akka://cluster-system/system/sharding/fileRouterProxyProxy to akka://cluster-system/system/sharding/fileRouterProxyCoordinator/singleton/coordinator was not delivered. [6] dead letters encountered. If this is not an expected behavior then akka://cluster-system/system/sharding/fileRouterProxyCoordinator/singleton/coordinator may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
  

Однако эти отправки успешны.

 region1 <! { ProgramId = "d"; Duration = TimeSpan.FromMinutes 8.; FilePath = "\a_2.mp4" }
region2 <! { ProgramId = "a"; Duration = TimeSpan.FromMinutes 10.; FilePath = "\a_1.mp4" }
  

Извините,
Как мне правильно создать shardingcoordinator?

Или, если это было неверно, в чем проблема с использованием shardingcoordinator, подобного этому?

Ответ №1:

Имя было неправильным, измените код следующим образом, и все будет в порядке!

 let shardRegionProxy = spawnShardedProxy extractorFunction system1 "fileRouter" (Some "Worker")