Administration guide > Configure the deployment environment > Configuring clients
Configure request retry timeout values
With reliable maps, you can supply a retry timeout value in milliseconds to WebSphere eXtreme Scale for transaction requests.
You can configure the timeout value on the client properties file or in a session. The session value overrides the client properties setting. If the value is set to greater than zero, the request is tried until either the timeout condition is met or a permanent failure occurs. A permanent failure might be a DuplicateKeyException exception. A value of zero indicates the fail-fast mode setting and eXtreme Scale does not attempt to try the transaction again after any type of transaction.
During run time, the transaction timeout value is used with the retry timeout value, ensuring that the retry timeout does not exceed the transaction timeout.
Two types of transactions exist: Autocommit transactions, and transactions that use explicit begin and commit methods. The valid exceptions for retry differ between these two types of transactions:
- For transactions that are called within a session, transactions are tried again for CORBA SystemException and eXtreme Scale TargetNotAvailable exceptions.
- For autocommit transactions, the transactions are tried again for CORBA SystemException and eXtreme Scale auvailability exceptions. These exceptions include the ReplicationVotedToRollbackTransactionException, TargetNotAvailable, and AvailabilityException exceptions. See Use sessions to access data in the grid for more information about autocommit transactions.
Application or other permanent failures return immediately and the client does not try the transaction again. These permanent failures include the DuplicateKeyException and KeyNotFoundException exceptions. Use the fail-fast setting to return all exceptions without trying transactions again after any exceptions.
Exceptions where the client tries the transaction again:
- ReplicationVotedToRollbackTransactionException (only on autocommit)
- TargetNotAvailable
- org.omg.CORBA.SystemException
- AvailabilityException (only on autocommit)
- LockTimeoutException (only on autocommit)
- UnavailableServiceException (only on autocommit)
Permanent exceptions, where the transaction is not tried again:
- DuplicateKeyException
- KeyNotFoundException
- LoaderException
- TransactionAffinityException
- LockDeadlockException
- OptimisticCollisionException
Procedure
- Set the timeout value in a client property file.
To set the requestRetryTimeout value on a client, add or modify the requestRetryTimeout property in the Client properties file. The client properties is the objectGridClient.properties file by default. The requestRetryTimeout property is set in milliseconds. Set the value greater than zero for the request to be retried on exceptions for which retry is available. Set the value to 0 to fail without retries on exceptions.
To use the default behavior, remove the property or set the value to -1. An example of the value in the objectGridClient.properties file follows:
requestRetryTimeout = 30000
The requestRetryTimeout value is specified in milliseconds. In the example, if the value is used on an ObjectGrid instance, the requestRetryTimeout value is 30 seconds.
- Set the timeout value programmatically.
To set the client properties programmatically, first create a client properties file in an appropriate <location> for your application. In the following example, the client properties file refers to the objectGridClient.properties snippet in the previous section. After you connect to ObjectGridManager instance, set the client properties as described. Then, when you have an ObjectGrid instance, the instance has the client properties you defined in the file. If you change the client properties file, explicitly get a new ObjectGrid instance each time.
ObjectGridManager manager = ObjectGridManagerFactory.getObjectGridManager(); String objectGridName = “testObjectGrid”; URL clientXML = null; ClientClusterContext ccc = manager.connect("localhost:2809", null, clientXML); File file = new File("<location>/objectGridClient.properties"); URL url = file.toURI().toURL(); ccc.setClientProperties(objectGridName, url); ObjectGrid objectGrid = ogManager.getObjectGrid(ccc, objectGridName);
- Set the override file during a session commit.
To set the request retry timeout on a session or to override the requestRetryTimeout client property, call the setRequestRetryTimeout(long) method on the Session interface.
Session sessionA = objectGrid.getSession(); sessionA.setRequestRetryTimeout(30000); ObjectMap mapA = sessionA.getMap("payroll"); String key = "key:" + j; mapA.insert(key, "valueA");
This session now uses a requestRetryTimeout value of 30000 milliseconds or 30 seconds, regardless of the value that is set in the client properties file. For more information on the session interface, see Use Sessions to access data in the data grid.
Parent topic:
Configure clients
Related concepts
Configure clients with WebSphere eXtreme Scale
Enable the client invalidation mechanism
Related reference