0

I think it is something wrong with my zmq.jar so I tried with jeroMQ but I have the same problem.

This is my method:

private boolean submitEvent(String ioMessage) {
    log.info("SEND");

    ZMQ.Context context = ZMQ.context();

    ZMQ.Socket sender = context.socket(ZMQ.PUSH);

    sender.connect("tcp://localhost:8086");

    sender.send("MESSAGE");

    return true;

}

I have a script in python which is PULL and if I try a push script also in python, it receives everything.

So my problem is in java.

I see in logs the first line ("send") but I haven't receive anything in the script.

What should I change?

Biribu
  • 3,615
  • 13
  • 43
  • 79

1 Answers1

1

From the Common mistakes at JeroMQ Wiki

  • Close all the sockets properly otherwise Context.term() will wait forever

So your final code shoul be

private boolean submitEvent(String ioMessage) {

    log.info("SEND");

    ZMQ.Context context = ZMQ.context();

    ZMQ.Socket sender = context.socket(ZMQ.PUSH);

    sender.connect("tcp://localhost:8086");

    sender.send("MESSAGE");

    sender.close();

    context.term(); 

    return true;

}
vzamanillo
  • 9,905
  • 1
  • 36
  • 56
  • Thanks but I checked the log and I found that the problem comes because of: java.lang.NoClassDefFoundError: org/jeromq/ZContext but I don't know why because it is in the project – Biribu Apr 01 '14 at 11:08
  • Yep, I had to change the route of my jeromq.jar I had to put inside project, not just add it to library path. Thanks man – Biribu Apr 01 '14 at 11:39