1

我成功创建了发布者,但未能使用以下内容创建订阅者:

    public static void main(String [] args)
    {
        ActorSystem system = ActorSystem.create("System");
        ActorRef subscriber = system.actorOf(new Props(Sub.class),   "subscriber");    
        subscriber.tell(new MyActor("CharlieParker", 50, 25), subscriber);
    }
    public class Sub extends UntypedActor 
    {
        ActorRef subSocket = ZeroMQExtension.get(getContext().system()).newSubSocket(
        new Connect("tcp://127.0.0.1:1237"),
        new Listener(getSelf()), Subscribe.all());
    }

收到此错误:线程 [System-akka.zeromq.socket-dispatcher-7] 未捕获的错误正在关闭 JVM,因为 ActorSystem [System] java.lang.NoSuchMethodError 启用了“akka.jvm-exit-on-fatal-error” : org.zeromq.ZMQ$Poller.poll(J)J at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala:180) at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala: 179) 在akka.zeromq.ConcurrentSocketActor$$anonfun$receive$1.applyOrElse(ConcurrentSocketActor.scala:46) 在akka.actor.akka.zeromq.ConcurrentSocketActor.akka$zeromq$ConcurrentSocketActor$$doPoll(ConcurrentSocketActor.scala:197)。 ActorCell.receiveMessage(ActorCell.scala:425) at akka.actor.ActorCell.invoke(ActorCell.scala:386) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230) at akka.dispatch.Mailbox。在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 在 java.lang.Thread 的 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 运行(Mailbox.scala:212) .run(Thread.java:722)

这是什么意思?

4

2 回答 2

2

I had the same type of error while trying to work with akka-zeromq and did some investigation on the subject. So the situation is the following: the error message states that it didn't find a method long poll(long timeout) in the class ZMQ.Poller (see this answer for the error message interpretation). This happens because of the following reasons

  1. Akka is built with zeromq-scala bindings.
  2. zeromq-scala is supposed to be compatible with jzmq , but unfortunately it's not at the moment because in scala bindings you have method long poll(long timeout) while in jzmq you have int poll(long timeout)

To overcome your problem locally you either have to rebuild Akka with zmq.jar, or use a quick and dirty workaround: change the return type for the method poll(long timeout) in jzmq ZMQ.Poller class and rebuild the java bindings. For more details and bindings compatibility discussion take a look here

However there is a global java/scala bindings compatibility problem, but it's outside of the scope of your question.

于 2013-05-29T08:49:36.600 回答
0

似乎您在路径上丢失或使用了错误版本的 zeromq-scala-binding。

您使用的是哪个版本的 akka 和 zeromq?

于 2013-04-30T10:57:10.043 回答