How is the batch asynchronous approach with the intuit SDK any different to the batch synchronous approach?

315 Views Asked by At

I have looked at the documentation for both synchronous and asynchronous approaches for the QuickBooks Online API V3. They both allow the creation of a data object and the adding of requests to a batch operation followed by the execution of the batch. In both the documentations they state:

"Batch items are executed sequentially in the order specified in the request..."

This confuses me because I don't understand how asynchronous processing is allowed if the batch process executes each batch operation sequentially.

The documentation for asynchronous processing states at the top:

"To asynchronously access multiple data objects in a single request..."

I don't understand how this can occur if batch operations are executed sequentially within a batch process request.

Would someone kindly clarify.

1

There are 1 best solutions below

0
On BEST ANSWER

In asyn call( from devkit ), calling thread doesn't wait for the response from service. You can associate a handler which will take care of that.

for Ex -

public void asyncAddAccount() throws FMSException, Exception {

    Account accountIn = accountHelper.getBankAccountFields();
    try {
        service.addAsync(accountIn, new CallbackHandler() {
            @Override
            public void execute(CallbackMessage callbackMessage) {
                callbackMessageResult = callbackMessage;
                lock_add.countDown();
            }
        });
    } catch (FMSException e) {
        Assert.assertTrue(false, e.getMessage());
    }
    lock_add.await();
    Account accountOut = (Account) callbackMessageResult.getEntity();
    Assert.assertNotNull(accountOut);
    accountHelper.verifyAccountFields(accountIn, accountOut);
}

Server always executes the requests sequentially. In a batch, if you specify multiple operations, then server will execute it sequentially (top - down).

Thanks