Pergunta

Questuion

I'm trying to implement a simple actor that will receive messages from zeromq using akka-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()
}

The system prints just

M: Connecting

Additional information

Sending messages is done via a simple python

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

The other strange thing I noticed is that ever after pressing enter the program will not terminate. It will if I send it a message using the python script. Here is the full output:

[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

Using

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 is version 3.2.2 (on Arch Linux)

This is the application.conf

akka {
  loglevel = DEBUG
  zeromq {
    socket-dispatcher {
      executor = thread-pool-executor
      type = "PinnedDispatcher"
    }
  }
}
Foi útil?

Solução

Ok, found the issue. It's the libzmq library version. Downgrading the library to 2.2 works. I've created a ticket for the Akka team: https://www.assembla.com/spaces/akka/tickets/2769-akka-zeromq-doesn-t-receive-messages-with-libzmq-3-2#/activity/ticket:

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top