[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: LargeMessage & Failover Update
clebert.suconic@jboss.com
do-not-reply at jboss.com
Wed Jan 14 17:07:21 EST 2009
- If we wait the replicatePacket to finish, largeMessageDeliver.deliver will be done asynchronously
| private void deliverLargeMessage(final MessageReference ref, final ServerMessage message)
| {
| .....
|
|
| if (!replicating)
| largeMessageDeliver.deliver(); // synchronous call when not replicating
|
| else
| result.setResultRunner(new Runnable() // asynchronous call when replicating
| {
| public void run()
| {
| largeMessageDeliverer.deliver();
| }
|
| });
| }
|
- the method doHandle which is calling deliverLargeMessage, will return immediately, while the server is still deliveringChunks to the client.
(promptDelivery BTW will try to send another message to the consumer, but it will be rejected as BUSY)
- As the ServerSessionPacketHandler is free, credits will arrive concurrently with the delivery to the client, instead coming after deliver returned. This following logic on receiveCredits will not work:
| public void receiveCredits(final int credits) throws Exception
| {
| if (credits == -1)
| {
| // No flow control
| availableCredits = null;
| }
| else
| {
| int previous = availableCredits.getAndAdd(credits);
|
| if (previous <= 0 && previous + credits > 0)
| {
| promptDelivery(); // this is what would resume the delivery of the largeMessage
| }
| else
| {
| log.info("Previous was not 0");
| }
| }
| }
|
- because of the credits coming on a different order than how they would usually come, the delivery of messages is interrupted. We will get the credit before they came negative.. so nothing will resume delivery.
If we called largeMessageDeliver.deliver() synchronously the credits would only arrive at the right time and the resume would work without any problem.
- We could of course make place the receiveCredits on an executor, scheduling the credit to be added as soon as the largeMessageSender is finished, or play with locks, but that seems weird to me and besides would cause implications on the regular use-case which is sending regular messages.
Making the call to largeMessageDeliverer.deliver synchronously would be the easiest solution, where I don't need to use any locks or executors, and believe on the natural order of credits that are coming from the client.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201951#4201951
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4201951
More information about the jboss-dev-forums
mailing list