Akka-zeromq socket / actor不会收到消息

时间:2012-12-04 16:05:02

标签: scala akka zeromq akka-zeromq

Questuion

我正在尝试实现一个简单的actor,它将使用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")

我注意到的另一个奇怪的事情是,在按下输入后,程序将不会终止。如果我使用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"
    }
  }
}

1 个答案:

答案 0 :(得分:0)

好的,发现了这个问题。这是libzmq库版本。将库降级为2.2可以正常工作。我为Akka团队创建了一张票:https://www.assembla.com/spaces/akka/tickets/2769-akka-zeromq-doesn-t-receive-messages-with-libzmq-3-2#/activity/ticket