For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Product
Category
Language
Format
SDK
Sort by
Direction

JAVA SDK: Programming practice on retries

  • Answer ID 474
  • Published 11/11/2013 10:40 AM
  • Updated 11/11/2013 10:40 AM
  • Permalink https://ebaydts.com/eBayKBDetails?KBid=474
Product
How to set retries using JAVA SDK framework?

Access to any web service can be bumpy at times (networking issues for example), so how to handle error and act upon them is very important.

There are two types of errors when communicating with the eBay API Web Service: Infrastructure Errors and Application errors.
Infrastructure errors are either caused by the client application or the eBay API server. Both server faults and client faults are wrapped in SdkSoapException in the eBay SDK JAVA framework.


Infrastructure Errors
A. Server faults : Retry three times when a Server fault is encountered
- (500)Internal Server Error
- A database connection error occurred
- org.xml.sax.SAXParseException: Premature end of file
- (502)Proxy Error
- java.net.SocketTimeoutException: Read timed out

B. Client faults: Retry three times when a client fault is encountered. Verify the data in your request if the request still fails after three retries.
- Request authentication failures ( Error 931).

Application errors are wrapped in ApiException in JAVA SDK.
- Do not retry if request contains an invalid combination of fields.
- Do not retry if a required field is missing in the request.
- Do retry three times if API server returns 10007 error (“Internal error to the application”) and report the incident via Premium Support.

The SDKs makes it very simple to implement retry for a call. Instantiate an object of the CallRetry class, set the number of retries and the retry time interval, and register the exception classes and error codes for which you want to retry. Retry will be executed if either condition is met.

// Instantiate new CallRetry object and set properties.
CallRetry callretry = new CallRetry();
callretry.setMaximumRetries(3);
callretry.setDelayTime(1000);

// Register API Error Codes
Token[] apiErrorCodes = new Token[] {
new Token('10007'),
new Token('')};
callretry.setTriggerApiErrorCodes(apiErrorCodes);

// Register exception classes
java.lang.Class[] tcs = new java.lang.Class[] {
        SocketTimeoutException.class,
        com.ebay.sdk.SdkSoapException.class };
Callretry.setTriggerExceptions(tcs);

// Register retry object with Api context
ApiContext.setRetry(callretry);



How well did this answer your question?

Answers others found helpful

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter