Forum: Building VoltDB Clients

Post: Mixing asynchronous and synchronous calls

Mixing asynchronous and synchronous calls
kdombeck
Nov 18, 2010
Are all asynchronous and synchronous calls processed in the order in which they were executed from the client side?
Example:
If this asynchronous call is made first
client.callProcedure(new MyCallback(), "UpdateCustomerBalance", customerId, newBalanceValue};
Then immediately following the previous asynchronous the following synchronous call is made, either by the same thread or another thread with the same client
VoltTable[] results = client.callProcedure("SelectCustomerBalance", customerId};
Will the second call be guaranteed to be executed after the first?
re: Mixing asynchronous and synchronous calls
tcallaghan
Nov 18, 2010
Ken,
To guarantee that transaction B executes after transaction A you need to do 1 of the following:
1. Synchronously issue transaction A then synchronously/asynchronously issue transaction B from the same client.
2. Asynchronously issue transaction A then asynchronously issue transaction B from the callback of transaction A.
3. Ensure that both transactions are received at the same node in the cluster in the order A then B.
In your example it is important to understand that it doesn't necessarily matter how the transactions are issued from the client (asynchronously or synchronously), what is important is the order they are received and then globally ordered for execution.
Ariel did a great blog post on "Living the Asynchronous Lifestyle" I think it is a worthwhile read for anyone writing VoltDB client applications.
-Tim