0

问题

我正在尝试实现一个简单的参与者,它将使用 akka-zeromq 从 zeromq 接收消息。

import akka.actor._
import akka.zeromq._

class PullActor extends Actor {
  def receive = {
    case x => println("M: " + x.toString)
  }
}

object Main extends App {
  val system = ActorSystem("system")

  val pullActor = system.actorOf(Props[PullActor], "pull-actor")

  val pullSocket = ZeroMQExtension(system).newSocket(
    SocketType.Pull, Listener(pullActor), Connect("tcp://127.0.0.1:8008"))

  println("Press ENTER to exit")
  Console.readLine()
  system.shutdown()
}

系统只打印

M: Connecting

附加信息

发送消息是通过一个简单的 python 完成的

import zmq
ctx = zmq.Context()
p = ctx.socket(zmq.PUSH)
p.bind("tcp://*:8008")
p.send("test")

我注意到的另一件奇怪的事情是,在按下 enter 后,程序不会终止。如果我使用 python 脚本向它发送消息,它会。这是完整的输出:

[DEBUG] [12/04/2012 18:01:45.175] [main] [EventStream(akka://system)] logger log1-Logging$DefaultLogger started
[DEBUG] [12/04/2012 18:01:45.178] [main] [EventStream(akka://system)] Default Loggers started
Press ENTER to exit
M: Connecting

[DEBUG] [12/04/2012 18:01:54.176] [system-akka.actor.default-dispatcher-2] [EventStream] shutting down: StandardOutLogger started
[DEBUG] [12/04/2012 18:01:54.176] [system-akka.actor.default-dispatcher-2] [EventStream] shutting down: StandardOutLogger started
[DEBUG] [12/04/2012 18:01:54.179] [system-akka.actor.default-dispatcher-2] [EventStream] all default loggers stopped

使用

scalaVersion := "2.10.0-RC3"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.1.0-RC3" cross CrossVersion.full,
    "com.typesafe.akka" %% "akka-zeromq" % "2.1.0-RC3" cross CrossVersion.full,
    "com.typesafe.akka" %% "akka-slf4j" % "2.1.0-RC3" cross CrossVersion.full
)

libzmq是版本3.2.2(在 Arch Linux 上)

这是application.conf

akka {
  loglevel = DEBUG
  zeromq {
    socket-dispatcher {
      executor = thread-pool-executor
      type = "PinnedDispatcher"
    }
  }
}
4

1 回答 1

0

好的,找到问题了。这是 libzmq 库版本。将库降级到 2.2 有效。我为 Akka 团队创建了一张票:https ://www.assembla.com/spaces/akka/tickets/2769-akka-zeromq-doesn-t-receive-messages-with-libzmq-3-2#/活动/门票

于 2012-12-05T09:40:09.570 回答