मैं व्यवहार के साथ एक अभिनेता है:निवर्तमान कनेक्शन धारा को बंद कर दिया
def receive: Receive = {
case Info(message) =>
val res = send("INFO:" + message)
installAckHook(res)
case Warning(message) =>
val res = send("WARNING:" + message)
installAckHook(res)
case Error(message) =>
val res = send("ERROR:" + message)
installAckHook(res)
}
private def installAckHook[T](fut: Future[T]): Unit = {
val answerTo = sender()
fut.onComplete {
case Success(_) => answerTo ! "OK"
case Failure(ex) => answerTo ! ex
}
}
private def send(message: String): Future[HttpResponse] = {
import context.system
val payload: Payload = Payload(text = message,
username = slackConfig.username, icon_url = slackConfig.iconUrl,
icon_emoji = slackConfig.iconEmoji, channel = slackConfig.channel)
.validate
Http().singleRequest(RequestBuilding.Post(slackConfig.hookAddress, payload))
}
और एक परीक्षण
val actorRef = system.actorOf(SlackHookActor.props(SlackEndpointConfig(WebHookUrl,iconEmoji = Some(":ghost:"))))
actorRef ! Error("Some error message")
actorRef ! Warning("Some warning message")
actorRef ! Info("Some info message")
receiveN(3)
और afterAll()
विधि में मैं TestKit
का उपयोग कर अभिनेता सिस्टम पर एक बंद करो।
यह काम करता है, अनुरोध सर्वर के लिए बनाता है, लेकिन वहाँ अक्का से त्रुटियाँ हैं हिस्सा धाराओं:
[ERROR] [06/26/2015 11:34:55.118] [SlackHookTestingSystem-akka.actor.default-dispatcher-10] [ActorSystem(SlackHookTestingSystem)] Outgoing request stream error (akka.stream.AbruptTerminationException)
[ERROR] [06/26/2015 11:34:55.120] [SlackHookTestingSystem-akka.actor.default-dispatcher-13] [ActorSystem(SlackHookTestingSystem)] Outgoing request stream error (akka.stream.AbruptTerminationException)
[ERROR] [06/26/2015 11:34:55.121] [SlackHookTestingSystem-akka.actor.default-dispatcher-8] [ActorSystem(SlackHookTestingSystem)] Outgoing request stream error (akka.stream.AbruptTerminationException)
लगता है की तरह के बाद से मैं एक भविष्य बाहर जाने वाले कनेक्शन पहले से ही बंद किया जाना चाहिए पूरा है, तो है यह एक बग है या मैं sth याद कर रहा हूँ?
मैं एक ही समस्या है प्रदान करता है। किसी भी मदद के लिए धन्यवाद। – jiangok
हमें अक्का-स्ट्रीम के लिए शटडाउन पैटर्न की आवश्यकता है। चूंकि प्रवाह कलाकार निहित हैं, इसलिए मुझे नहीं पता कि letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2 में उल्लिखित तकनीकों को लागू करना सही है या नहीं। – jiangok
आलस्य के लिए डाउनवॉटेड। न तो शीर्षक और न ही टैग कोई उपयोगी संदर्भ देते हैं। – mc0e