अभिनेता हो रही BufferOverflowException जब भेजने के एकल

0

सवाल

मैं कोशिश कर रहा हूँ करने के लिए भेजने के सैकड़ों से http अनुरोध अक्का अभिनेता हालांकि मैं हो रही हूँ

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)...

इस आवेदन.conf

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

इस कोड

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

मैं नियंत्रण करने की कोशिश की राज्य द्वारा ई । जी

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)))
        //...

या तो जिस तरह से मैं एक ही अपवाद के BufferOverflowException

किसी भी सलाह काफी सराहना की जाएगी

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

सबसे अच्छा जवाब

2

का उपयोग कर context एसिंक्रोनस रूप से एक Future एक बुरा विचार है. context यह केवल वैध कॉल के दौरान करने के लिए अभिनेता ।

बग है कि context.become(run(openRequests - 1)) का उपयोग करता है के मूल्य openRequests समय पर Future बनाई गई है, न कि मूल्य जब यह कहा जाता है । तो जब पहली अनुरोध को पूरा करती है यह फोन करेगा context.become(run(-1)) (जो स्पष्ट रूप से फर्जी) हो सकता है भले ही 15 बकाया अनुरोध.

समाधान के लिए एक निजी संदेश भेजने के लिए अपने आप में foreach के बजाय बुला context.become सीधे. जब अभिनेता संभालती है कि संदेश यह decrements के वर्तमान अनुरोध गिनती और भेजता है एक नया अनुरोध यदि आवश्यक हो तो.

2021-10-22 07:52:58

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................