Hi ,
I am trying the new ZeroMQ integration with a simple echo server like this ( using spring boot to fire it up):
@Bean
public Pipe[] zmqStart(Environment env, CountDownLatch latch) {
ZeroMQ<Buffer> zmq = new ZeroMQ<>(env);
Pipe taskQ = new Pipe();
zmq.reply("tcp://*:5555")
.onSuccess(ch -> {
//ch.when(Exception.class, err ->{
// logger.severe(err.toString());
//});
ch.on().close(new Runnable() {
@Override
public void run() {
logger.warning("Channel closed");
}
});
//taskQ.in = ch;
//logger.info("tasQ.in = " + ch);
})
.consume(ch -> {
Stream<Buffer> in = ch.in();
in.consume(req -> {
logger.warning("Consumed " + new String(req.asBytes()));
ch.send(req)
.onComplete(res ->{
// logger.warning(res.toString());
});
});
});
return new Pipe[]{taskQ};
}And simple python client to send messages :
#!/usr/bin/env python3
import zmq
context = zmq.Context()
# Socket to talk to server
print("Connecting to hello world server")
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
# Do 10 requests, waiting each time for a response
for request in range(10):
print("Sending request %s " % request)
socket.send(b"Hello")
# Get the reply.
message = socket.recv()
print("Received reply %s [ %s ]" % (request, message))And what happens is that I get two messages in the server :
2014-09-26 13:03:17.256 INFO 22690 --- [ zmq-server-16] reactor.net.zmq.tcp.ZeroMQTcpServer : BIND: starting ZeroMQ REP socket on tcp://*:5555
2014-09-26 13:03:17.485 INFO 22690 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2014-09-26 13:03:17.549 INFO 22690 --- [ main] z.c.c.xmlrpc.server.SimpleBroker : Started SimpleBroker in 4.654 seconds (JVM running for 5.152)
2014-09-26 13:03:29.730 WARN 22690 --- [ ringBuffer-9] ZMQ Echo : Consumed Hello
2014-09-26 13:03:29.736 WARN 22690 --- [ ringBuffer-9] ZMQ Echo : Consumed Helloand only two replies in the client :
Connecting to hello world server
Sending request 0
Received reply 0 [ b'Hello' ]
Sending request 1
Received reply 1 [ b'Hello' ]
Sending request 2
and at that point the client is just waiting for the 3rd reply, but there is no message received in the server. Also if I interrupt the client, and w/o restarting the server run the client again the same thing happens, I get only 2 messages.
Anybody has any clue why I get only 2 messages, and where does the 3rd go ? Is there any way to catch errors that the reactor has probably just ignored ?
Thanks,
Zaro