akka - zeromq - cannot run even a simple toy program.

231 views
Skip to first unread message

ankit master

unread,
Dec 1, 2014, 5:02:22 PM12/1/14
to akka...@googlegroups.com
Hello, 

I am using CentOS 6.4 and am running into all sorts of troubles running Akka zeromq. I have zeromq and jzmq installed on my machine (/usr/local/lib). I am writing this very simple toy program but fail to get it working, following is the code and its output, I would greatly appreciate all your help in getting this working. I tried for several days but all of my efforts seem to be futile. 

import akka.util.ByteString
import akka.zeromq._
import akka.actor._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global


class Sub extends Actor{
  def receive  = {
    //case m:ZMQMessage if m.frames(0).utf8String == "hello" => println(m.frames(1).toString())
    case m:ZMQMessage => println("************* from subscriber *****************") //;println(m.frames(1).toString())
    case ss :String => println (" ---- some string appeared ")
    case _ => println("something happened")
  }
}


class Pub extends Actor{

  //creates a publisher socket bound to host at port 1235
  val pubSocket = ZeroMQExtension(context.system).newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:1234"))

  def receive={
    case msg:String =>
      //println(s"Got Message $msg")
      pubSocket ! ZMQMessage(ByteString("hello"), ByteString("this is test message"))
  }
}

object main extends App {

  println("Starting App.")

  val system = ActorSystem("system")

  val pubActor = system.actorOf(Props[Pub])
  val subActor = system.actorOf(Props[Sub])

  
  // sockets are created using ZeroMQExtension
  // creates a subscriber socket
  val subSocket = ZeroMQExtension(system).newSocket(SocketType.Sub, Listener(subActor), Connect("tcp://127.0.0.1:1234"), SubscribeAll)

  system.scheduler.schedule(1 seconds, 0 minutes)(pubActor ! "Message to Pub")

  println("Exiting main.")
}


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


[info] Running main 
Starting App.
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/jna7282295364414175580.tmp which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exiting main.
something happened
[ERROR] [12/01/2014 13:50:41.500] [system-akka.actor.default-dispatcher-2] [akka://system/user/zeromq/$a] No such file or directory
org.zeromq.ZMQException: No such file or directory
at org.zeromq.ZMQ$Socket.raiseZMQException(ZMQ.java:480)
at org.zeromq.ZMQ$Socket.send(ZMQ.java:378)
at akka.zeromq.ConcurrentSocketActor.flushMessage(ConcurrentSocketActor.scala:161)
at akka.zeromq.ConcurrentSocketActor.akka$zeromq$ConcurrentSocketActor$$flush(ConcurrentSocketActor.scala:170)
at akka.zeromq.ConcurrentSocketActor$$anonfun$receive$1.applyOrElse(ConcurrentSocketActor.scala:50)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at akka.zeromq.ConcurrentSocketActor.aroundReceive(ConcurrentSocketActor.scala:30)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

[INFO] [12/01/2014 13:50:41.507] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.507] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.512] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [3] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.521] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [4] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.531] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [5] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.541] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [6] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.551] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [7] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.561] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [8] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.571] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [9] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [12/01/2014 13:50:41.582] [system-akka.actor.default-dispatcher-3] [akka://system/user/zeromq/$a] Message [akka.zeromq.ZMQMessage] from Actor[akka://system/user/$a#-1772810193] to Actor[akka://system/user/zeromq/$a#-1334917411] was not delivered. [10] dead letters encountered, no more dead letters will be logged. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.



Thank you in advance
Sincerely, 
AM

√iktor Ҡlang

unread,
Dec 2, 2014, 3:10:44 AM12/2/14
to Akka User List

Hi Ankit,

You omitted the version of 0mq you are using, did you check the docs for supported versions?

Cheers,
V

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

ankit master

unread,
Dec 2, 2014, 4:19:14 PM12/2/14
to akka...@googlegroups.com
Hello, 

Thank you very much for all your help, I was earlier using zeromq version 4.1 but downgraded it to 2.2 yesterday. Now my problem is that everytime when I run my example it always enters the case of connecting. Please advise if more information is needed. 

import akka.util.ByteString
import akka.zeromq._
import akka.actor._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global


class Sub extends Actor{
  def receive  = {
    //case m:ZMQMessage if m.frames(0).utf8String == "hello" => println(m.frames(1).toString())
    case m:ZMQMessage => println("************* from subscriber *****************") //;println(m.frames(1).toString())

    case ss :String => println (" ---- some string appeared ")

    case Connecting => println("connection issue")

    case default => println(s"Running default case -- Unexpected value $default")

    }
}


class Pub extends Actor{

  //creates a publisher socket bound to host at port 1235
  val pubSocket = ZeroMQExtension(context.system).newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:1234"))

  def receive={
    case msg:String =>
      //println(s"Got Message $msg")
      pubSocket ! ZMQMessage(ByteString("hello"), ByteString("this is test message"))
  }
}

object main extends App {

  println("Starting App.")

  val system = ActorSystem("system")

  val pubActor = system.actorOf(Props[Pub])
  val subActor = system.actorOf(Props[Sub])

  val subSocket = ZeroMQExtension(system).newSocket(SocketType.Sub, Listener(subActor), Connect("tcp://127.0.0.1:1234"), SubscribeAll)

  system.scheduler.schedule(10 seconds, 0 minutes)(pubActor ! "Message to Pub")

  println("Exiting main.")
}


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my build.sbt 

name := "Akka ZeroMQ Example"

version := "1.0"

scalaVersion := "2.10.4"


val akkaV = "2.3.6"

resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"

resolvers += "Sonatype (releases)" at "https://oss.sonatype.org/content/repositories/releases/"

libraryDependencies += "org.zeromq" %% "zeromq-scala-binding" % "0.0.6"

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % akkaV

libraryDependencies += "com.typesafe.akka" %% "akka-zeromq" % akkaV

libraryDependencies += "com.typesafe.akka" %% "akka-remote" % akkaV


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
output of the above program, 

info] Running main 
Starting App.
[DEBUG] [12/02/2014 13:18:48.481] [run-main] [EventStream(akka://system)] logger log1-Logging$DefaultLogger started
[DEBUG] [12/02/2014 13:18:48.482] [run-main] [EventStream(akka://system)] Default Loggers started
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/jna7595689729881225335.tmp which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exiting main.
connection issue               <-------------------------------------------------------------------- Output

√iktor Ҡlang

unread,
Dec 2, 2014, 4:27:28 PM12/2/14
to Akka User List

ankit master

unread,
Dec 3, 2014, 12:31:05 AM12/3/14
to akka...@googlegroups.com
Thank you again for you reply Victor. I referred the tests you pointed me at and I also consulted the Akka docs but none seem to help me in troubleshooting my issue. 

I even tried downloading some examples from github (apparently these examples are working examples) when I run these examples I land in the same situation, where my output is  "Connecting" (akka.zeromq.Connecting)



You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/BtFCLO-pE4U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.

To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--

From the withered tree, a flower blooms.
                                                         - Zen

Akka Team

unread,
Dec 4, 2014, 11:43:59 AM12/4/14
to Akka User List
Hi Ankit,

It seems like your VM exits prematurely, and have some issue with loading the native library. Akka zeroMQ now has this dependency:

"org.spark-project.zeromq" %% "zeromq-scala-binding" % "0.0.7-spark" // ApacheV2

I guess that your zeroMQ scala-binding version simply clashes with this dependency.

-Endre
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam
Reply all
Reply to author
Forward
0 new messages