[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Streamlined delivery of messages to consumer
timfox
do-not-reply at jboss.com
Sat Dec 23 15:38:26 EST 2006
I have refactored the way we deliver messages to consumers.
This has resulted in a major simplification of the code, aiding it's clarity and improving it's maintainability as well as hopefully being more performant.
The way it is designed to work is as follows:
The client side consumer has a local buffer with a max size of maxBufferSize - it always consumes messages locally from that buffer.
The server will send messages as fast as it can as they arrive to the consumer. It writes the messages onto the wire and doesn't wait for a response (i.e. it's not RPC - so we are not held ransom by networks with highbandwidth but high latency).
On the other end of the wire, messages are read off and added to the buffer.
If the buffer becomes full, because the consumer consumption rate cannot keep up with the rate the server is sending, then the client side consumer sends a flow rate change message to the server with an argument of zero.
(The flow rate change message is sent asynch from client to server and has a parameter "newRate" which means "please try and send messages at this new rate". Currently we are only binary, i.e. value = 0 means stop sending and value >0 means send as fast as you can. But this is a placeholder for the future where specific rates can be specified.)
The server receives the flow rate change (0) and stops sending messages. The client consumes the backlog and when the number remaining reaches bufferSize / 2 it sends another flow rate change message to the server with a +ve value.
The server receives this and starts sending again.
Note that we do not wait until the buffer is empty before sending the asynch flow rate change (+ve) message since this would introduce extra latency since the consumer wouldn't be consuming while it was waiting for new messages to arrive.
Currently we are waiting on remoting to release a version with true asynchronous invokes (which are in remoting HEAD but not in a release) but this is done we should see the benefits.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996046#3996046
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996046
More information about the jboss-dev-forums
mailing list