Aktör, Tek gönderirken BufferOverflowException alıyor

0

Soru

Akka aktöründen birkaç yüz http isteği göndermeye çalışıyorum ancak alıyorum

akka.stream.BufferOverflowException: Exceeded configured max-open-requests value of [16]. This means that the request queue of this pool (HostConnectionPoolSetup(places.api.here.com,443,ConnectionPoolSetup(ConnectionPoolSettings(16,1,5,16,1,Duration.Inf,100 milliseconds,2 minutes,30 seconds,ClientConnectionSettings(Some(User-Agent: akka-http/10.2.0)...

bu uygulama.conf

   http {
          host-connection-pool {
            max-connections = 16
            min-connections = 1
            max-open-requests = 16
          }
        }

Bu kod

override def receive: Receive = {
      case Foo(_) => 
       val res: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://..."))
   // do something for the result

Devlete göre kontrol etmeye çalıştım, örn.

override def receive: Receive = run(0)
def run(openRequests: Int) : Receive = {
  case Foo(_) if openRequests <= 16 => 
     context.become(run(openRequests + 1))
       val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://..."))
       responseFuture.foreach(context.become(run(openRequests - 1)))
        //...

her iki durumda da aynı istisnayı aldım BufferOverflowException

herhangi bir tavsiye çok takdir edilecektir

akka akka-http akka-stream scala
2021-10-22 05:31:19
1

En iyi cevabı

2

Kullanım context eşzamansız olarak bir Future kötü bir fikir. context bu sadece aktöre yapılan çağrılar sırasında geçerlidir.

Hata şu ki context.become(run(openRequests - 1)) değerini kullanır openRequests zamanda Future çağrıldığında değer değil, oluşturulur. Yani ilk istek tamamlandığında arayacak context.become(run(-1)) (ki bu açıkça sahtedir) ödenmemiş 15 talep olsa bile.

Çözüm, kendinize özel bir mesaj göndermektir. foreach aramak yerine context.become doğruca. Aktör bu iletiyi işlediğinde, geçerli istek sayısını azaltır ve gerekirse yeni bir istek gönderir.

2021-10-22 07:52:58

Diğer dillerde

Bu sayfa diğer dillerde

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................