[Design of Messaging on JBoss (Messaging/JBoss)] - Re: LargeMessage & Failover Update
by clebert.suconic@jboss.com
anonymous wrote :
| I'm not sure what do you mean by "called largeMessageDeliver.deliver() synchronously"
When replicating, the main method is not waiting deliver to finish and continuing its execution, hence asynchronous per definition.
When non replicating, the main is waiting deliver to finish, the main execution of the method is dependent on deliver finish, hence synchronous per definition.
The method deliverLargeMessage will return before largeMessageDeliver.deliver finished, as the method will be running on another thread.
Credits are arriving before the deliverLargeMessage was finished, hence the wrong order. The credits are arriving before the process finished which would be the natural order.
The correct order of credits is:
LargeMessageDeliver.deliverBegins:
- deliver LargeMessageHeader
while (credits)
{
- deliver LargeMessageChunks
}
creditsArriving *should arrive* after LargeMessageDeliver was finished.
This is happening because the ServerPacketHandler is not locked, and being able to be receive CreditPackets as the chunks are being sent to the client.
We would need to lock the credit receiving somehow until deliverLargeMessage is finished, but waiting the execution to finish would give you that lock naturally.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4202120#4202120
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4202120
17 years, 2 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: LargeMessage & Failover Update
by timfox
"clebert.suconic(a)jboss.com" wrote : - 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 of coming after the method 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
| | }
| | }
| | }
| |
|
|
| - because of the credits coming on a different order than how they would usually come,
|
The order the the credits arrive on the server should be the same. How is this different? The only way the credits could arrive in a different order on the server is if the client sent them in a different order. How is this the case? I think it needs more explanation....
anonymous wrote :
| 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.
|
I'm not sure what do you mean by "called largeMessageDeliver.deliver() synchronously"
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4202059#4202059
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4202059
17 years, 2 months