Hi.  I wonder if anyone can help or has tips on how to diagnose this
problem?...

I have written a Java program to upload products to Google Base using
the data API in batch mode.  The program determines what products are
to be amended and then builds and sends the appropriate batch
requests, e.g. inserts, updates or deletes.  Each batch contains 10
entries.  For example, if we have 21 inserts and 5 deletes then 3
insert batches would be sent and 1 delete batch.  To reduce the load
on Google, there is a 2 second sleep after each batch.

The program works fine when there are less than about 30 products.
However, if more than this then after a couple of batches have been
sent then Google stops responding and a time-out exception is thrown -
Error: Read timed out (I've set the timeout to 10 minutes).

Any ideas why Google should stop responding when so little data has
been transferred?

This is an outline of the code:

        /* Set-up Google service. */
        GoogleBaseService service =
                new GoogleBaseService(APPLICATION_NAME, googleFeedDeveloperKey);
        service.setUserCredentials(googleFeedEmail, googleFeedPassword);
        service.setReadTimeout(GOOGLE_BASE_SERVICE_TIMEOUT /*10 mins*/);
        service.setConnectTimeout(GOOGLE_BASE_SERVICE_TIMEOUT /*10 mins*/);
.
For inserts (it is a similar for deletes and updates):
.
        URL url = new URL("http://www.google.com/base/feeds/items";);
        GoogleBaseFeed feed = service.getFeed(url);

        Link batchLink = feed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
        URL batchUrl = new URL(batchLink.getHref());

        < loop for all products >

                < loop for just 10 products (i.e. each batch contains 10 
entries) >

                        < read productRec from database >

                        GoogleBaseEntry entry = new GoogleBaseEntry();
                        feed.addEntry(entry);

                        
entry.setTitle(TextConstruct.create(TextConstruct.Type.TEXT,
productRec.Title, null));
                        
entry.setContent(TextConstruct.create(TextConstruct.Type.TEXT,
productRec.Description, null));
                        entry.addHtmlLink(productRec.URL, null, null);
                        entry.getGoogleBaseAttributes().setItemType("Products");
                        entry.getGoogleBaseAttributes().addTextAttribute("id",
productRec.ID);
                        
entry.getGoogleBaseAttributes().addImageLink(productRec.ImageURL);
                        
entry.getGoogleBaseAttributes().addTextAttribute("currency",
"GBP");
                        
entry.getGoogleBaseAttributes().addFloatAttribute("price",
productRec.Price);
                        
entry.getGoogleBaseAttributes().addIntAttribute("quantity",
productRec.Quantity);
                        
entry.getGoogleBaseAttributes().addTextAttribute("condition",
productRec.ProductCondition);
                        
entry.getGoogleBaseAttributes().addTextAttribute("item_language",
"en");
                        
entry.getGoogleBaseAttributes().addTextAttribute("target_country",
"GB");

                        /* Calculate expire date. */
                        Calendar cal = Calendar.getInstance();
                        cal.add(Calendar.DATE, REFRESHDAYS);
                        entry.getGoogleBaseAttributes().setExpirationDate(new 
DateTime
(cal.getTime()));

                        /* Mark for INSERT. */
                        BatchUtils.setBatchOperationType(entry,
BatchOperationType.INSERT);

                        /* Assign a unique ID for tracking. */
                        BatchUtils.setBatchId(entry, ""+googleTrackerID);

                < end inner loop >

                /* Send batch of 10 entries. */
                GoogleBaseFeed result = service.batch(batchUrl, feed);

                *** GOOGLE STOPS RESPONDING AFTER ABOUT 2 BATCHES HAVE BEEN 
SENT.
***

                < handle response >

                /* Batch sent - Reset data structure. */
                feed = service.getFeed(url);

                <snooze for 2 seconds>

        < end outer loop >

Thanks,
john
-- 
You received this message because you are subscribed to the Google Groups 
"Google Base Data API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-base-data-api?hl=en.


Reply via email to