[Spread-users] Listener performance vs. receive() performance

John Keating jkeating at ca.afilias.info
Mon Feb 11 16:14:54 EST 2008


I'm trying out Spread 4.0 Java interface.  As opposed to sitting on 
connection.receive(), the BasicMessageListener interface is appealing 
since you can have multiple listeners on one connection.

If I use a single Java class to open the connection and read messages in 
either mode, all is well.  If instantiate a second class to read 
messagesin either mode, all is well.  The issue is when the second class 
both extends Thread and acts as a listener.   Looking at the the test 
classes User.java and recThread.java as examples, I created a class that 
does both - extends Thread (like recThread.java) and implements the 
BasicMessageListener interface.  I added the connection.receive() also 
so this second class can receive messages either as a listener or by 
blocking on connection.receive().  If I create the Thread object and 
tell it to block on the connection.receive() , it's very fast.  If I 
create the Thread object and tell it to listen, it's much, much slower - 
maybe 10 times slower.

Each Spread message's payload - the byte[] data - conains an ASN.1 
encoded Java object.   When the message is received in either mode, the 
byte array is decoded back into the Java object and some of the data is 
displayed (message number).

Does this performance difference ring a bell with anyone?

More information about the Spread-users mailing list