Question

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?

Was it helpful?

Solution

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;

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top