Question

I'm trying to optimize my application to perform at maximum speed. I intended on having two threads each executing a batch request of sales receipts additions. I also intended on having two parallel threads each with a batch request of customer additions. I was wondering whether this is possible or would the API lock the sales receipt/customer table in QuickBooks thus only allowing one thread to perform.

From my research I know that there a three types of entities (Name list, transaction and supporting entities). So what are the causes of locks on these entities, ie what scenario's will cause a lock? Is there any documentation on this matter I couldn't seem to find any?

Thanks

Was it helpful?

Solution

Lock is applicable for Name entities(Vendor, Customer and Employee ). While creating a new name entity, service ensures that an unique name is getting inserted in cloud. So, it puts a lock across all names of these 3 entities.

You can try this scenario using a decent payload.

public static void main(String args[]) {
    PropertyConfigurator
            .configure("log4j.properties");
    Config.setProperty(Config.SERIALIZATION_REQUEST_FORMAT, "xml");
    Config.setProperty(Config.SERIALIZATION_RESPONSE_FORMAT, "xml");

    final Context platformContext = getPlatformContext("QBO");  
    final QBOV3ProdTest qbov3ProdTest = new QBOV3ProdTest(platformContext);

    Thread customerThread = new Thread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 15; i++) {
                qbov3ProdTest.addCustomer();
            }
        }
    });
    customerThread.start();

    Thread vendorThread = new Thread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 15; i++) {
                qbov3ProdTest.addVendor();
            }
        }
    });
    vendorThread.start();

}

private void addCustomer() {
    Customer customer = new Customer();
    customer.setDisplayName("TestCustomer-" + staticCount++);
    try {
        this.service.add(customer);
    } catch (FMSException e) {
        e.printStackTrace();
    }
}

private void addVendor() {
    Vendor vendor = new Vendor();
    vendor.setDisplayName("TestVendor-" + staticCount++);
    try {
        this.service.add(vendor);
    } catch (FMSException e) {
        e.printStackTrace();
    }
}

Service doesn't return a proper response. Wherever it fails, service returns 401. Please let me know if you can reproduce this behaviour while trying this use-case in your test QBO account.

Thanks

OTHER TIPS

This is not exactly a DB locking rule but because of the way we are saving data to our cache for Names lists.

We do not allow users to update these entities in a multi-threaded manner:

Account, Department, Item, Class, Customer, Employee, Vendor, PaymentMethod, Terms.

The above has been confirmed by our engineering team.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top