Hot questions for Using ZeroMQ in akka zeromq


I am building app with Scala 2.12.6,Akka and zeroMQ I am trying to add dependency for zeroMQ like this but facing issues while downloading dependencies for zeroMQ. I am trying to add ZeroMQ dependency like this :

val `akka-zeromq`     = "com.typesafe.akka"      %% "akka-zeromq"   % "2.1-M1"

Below section explains sbt resolvers I am using : resolvers += Resolver.url("bintray-sbt-plugins", url(""))(Resolver.ivyStylePatterns), resolvers += Resolver.bintrayRepo("pqw", "maven"), version := "0.0.1", fork := true, parallelExecution in Test := false, autoCompilerPlugins := true, if (formatOnCompile) scalafmtOnCompile := true else scalafmtOnCompile := false

I think I did everything correct but still facing below issues while trying to run project with command sbt stage publishLocal

[warn]  module not found: com.typesafe.akka#akka-zeromq_2.12;2.1-M1
[warn] ==== local: tried
[warn]   /home/mahendratonape/.ivy2/local/com.typesafe.akka/akka-zeromq_2.12/2.1-M1/ivys/ivy.xml
[warn] ==== public: tried
[warn] ==== local-preloaded-ivy: tried
[warn]   /home/mahendratonape/.sbt/preloaded/com.typesafe.akka/akka-zeromq_2.12/2.1-M1/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:////home/mahendratonape/.sbt/preloaded/com/typesafe/akka/akka-zeromq_2.12/2.1-M1/akka-zeromq_2.12-2.1-M1.pom
[warn] ==== bintray-sbt-plugins: tried
[warn] ==== bintray-twtmt-maven: tried
[warn] ==== mavenRepo: tried
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.akka#akka-zeromq_2.12;2.1-M1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  Note: Unresolved dependencies path:
[warn]      com.typesafe.akka:akka-zeromq_2.12:2.1-M1 (/home/mahendratonape/abc4.0/acs/build.sbt#L8)
[warn]        +- org.tmt:abc-asd_2.12:0.0.1

Please let me know if you can provide any help for this.


From what I can see on, version M-1 is not released on maven central, but exists on typesafe repo.

I tried with this minimal example:

resolvers += "Typesafe maven releases" at ""

libraryDependencies += "com.typesafe.akka" % "akka-zeromq" % "2.1-M1"

Reload sbt and update. Maybe try newer dependency version.


I'm interested in trying to see how I might leverage the Akka/ZeroMQ module in my project.

In that document, 4 so-called "messaging patterns" are identified but only 1 (Pub-Sub) are explained in detail. They are:

  1. Pub-Sub
  2. Router-Dealer
  3. Push-Pull
  4. Rep-Req

To me (a messaging greenhorn), I don't understand how there could be anything more than Pub-Sub: you have a message, you publish it to a broker, and another process (subscriber) consumes it from the broker.

So my specific question is: what are some concrete use cases for each message ZeroMQ pattern, and why would I ever want to utilize each pattern if Akka already has a mechanism for communicating between threads?

I ask this because the documentation linked above simply states "More documentation and examples will follow soon." for all patterns except Pub-Sub.


Before going into more details right for your question, kindly check another Answer almost identical to your one >>>

Q: What are some concrete use cases for each message ZeroMQ pattern

A: Best proceed with the book, you will find many indispensable comments and remarks there

Q: .. don't understand how there could be anything more than Pub-Sub

A: Oh yes, there is a complete new Universe behind that. ZeroMQ is broker-less, zero-copy, incredibly fast to touch just a few ( read below )

Q: why would I ever want to utilize each pattern if Akka already has a mechanism for communicating between threads?

A: Well, it depends. If you are happy with message passing performance for just a few localhost threads ( not much above a few tens ), no need to invest your time into ZeroMQ. If going for high perormance, distributed, (almost) linear scaleability and heterogenous portability, well, then there might be the right time to start reading into ZMQ.

Several links to a few must-read-s

worth for shaping one's mind before moving into details from the ZeroMQ evangelists Pieter Hintjens & Martin Sústrik

An initial view on PUB/SUB from ( check and do not miss Martin's cool notes on unit-testing & other gems in his collection )

A very indepth must-have & must-read is a book ( available as pdf ) "Code Connected, Volume 1" If going seriously in for messaging, this is a basis to work with.

A collection of good whitepapers is on


I have the following control flow. In a for loop, I make an array of strings. I send out each row of the array (a string) to a publisher function. The publisher function then is supposed to send out the strings. I have a problem where my subscriber only receives messages, if the publisher is publishing in an infinite loop. Why can I not continuously call the publisher function and have it send data out? Why is it only working in an infinite loop?

Here is my publisher function:

    int zedMQserver(std::string output)

     //std ::cout << output.c_str()<< std:: endl;

zmq::context_t context (1);
zmq::socket_t publisher (context, ZMQ_PUB);
publisher.bind("ipc://device.ipc");                // Not usable on Windows.

    int i=1;   
    //while(1) {

    //  Send message to all subscribers

  const int SIZE = output.length();

    zmq::message_t message(SIZE+1);
    snprintf ((char *), (SIZE+1) ,
        "%s", output.c_str());
   std :: cout << "sent message" << std:: endl;
return 0;

Here is my subscriber function:

#include <zmq.hpp>
#include <iostream>
#include <sstream>

int main (int argc, char *argv[])


 zmq::context_t context (1);

 //Socket to talk to server
 std::cout << "Collecting updates from device server...\n" << std::endl;
 zmq::socket_t subscriber (context, ZMQ_SUB);
 const char *filter = (argc > 1)? argv [1]: "";  // no filter currently
 subscriber.setsockopt(ZMQ_SUBSCRIBE, filter, strlen (filter));
 //  Process 100 updates
 zmq::message_t update;

 for (int q =0 ; q<1000 ; q++) {

    std::string output = std::string(static_cast<char*>(, update.size());

    std:: cout <<output << std:: endl;       
 return 0;


Why is that when I take away the while(1) statement, I don't receive anything?


So it turns out that this is a classic "slow joiner problem". I made the publisher sleep a bit, and it worked.