- 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 became 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 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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...