[zeromq-dev] jeromq mdlclient2 loses/lost messages
Roger
roger.ne.ll at gmail.com
Fri Sep 6 23:09:10 CEST 2013
I'm using jeromq.
I ran the mdworker, mdbroker and mdclient2 (the async example) and the
client loses about 15% of the messages.
If I run msclient (sync example) all messages are received.
To exaggerate the message loss, and record the number of messages lost I
made a few changes to mdclient2.
----
import org.zeromq.ZMsg;
/**
* Majordomo Protocol client example, asynchronous. Uses the mdcli API to
hide
* all MDP aspects
*/
public class mdclient2 {
public static void main( String[] args ) throws Exception {
boolean verbose = ( args.length > 0 && "-v".equals( args[ 0 ] ) );
mdcliapi2 clientSession = new mdcliapi2( "tcp://localhost:5555", verbose
);
System.out.println( "Sending" );
int count, recvCount = 0;
for( count = 0; count < 100000; count++ ) {
ZMsg request = new ZMsg();
request.addString( "Hello world " + count );
clientSession.send( "echo", request );
}
System.out.println( "Sleeping" );
Thread.sleep( 5000 );
System.out.println( "Receiving" );
for( int i = 0; i < 100000; i++ ) {
ZMsg reply = clientSession.recv();
if( reply != null ) {
++recvCount;
reply.destroy();
}
else {
break;
}
}
System.out.printf( "%d requests, %d replies\n", count, recvCount );
clientSession.destroy();
}
}
More information about the zeromq-dev
mailing list