IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Outbound support
Manage stale connections
Connection-related problems can be resolved in your adapter using the two properties, connectionRetryLimit and connectionRetryInterval defined in the Managed connection factory of your adapter.
These two properties are used to provide the following features during outbound communication of the adapter and are optional by default.
- Retry mechanism as part of establishing the physical connection to the enterprise information system (EIS)
The adapter retries to establish physical connection (when physical connection is not established) for the connectionRetryLimit times with a time delay of connectionRetryInterval.
- Validating the EIS connection for each request based on the property connectionRetryLimit
- If the property connectionRetryLimit is set to 0 (zero), then adapter does not perform any EIS connection validation and executes the outbound operation. If the EIS connection is invalid, the outbound operation fails. Though the subsequent requests get executed provided the associated EIS system is functional, but the current request fails.
- If the property connectionRetryLimit is set to greater than 0 (zero), then during each request the adapter validates if the EIS connection is active or alive. If connection is valid then operation is completed as usual. If connection is invalid, adapter invalidates the current managed connection so that a new managed connection is created (new physical connection). If connection creation is successful then the outbound operation is completed otherwise an error ResourceException is displayed.
This feature has performance effects as adapter checks for validity of the connection for each request.
These features take care of connections which are timed out or became stale after EIS restarts. Even though this option solves most of connection-related problems, the adapter is not guaranteed to work 100 percent error free for connection problems.
Examples of connectionRetryLimit and connectionRetryInterval
Method for retry connection to EIS ( < AdapterPrefixName>ManagedConnection.java)private void getEISConnection(PasswordCredential pc, boolean reauthenticate) { // TODO int retryLimit = test_mcf.getConnectionRetryLimit(); if(retryLimit< 0){ retryLimit =0; } int retryInterval = test_mcf.getConnectionRetryInterval(); //TODO for(int i =0; i<=retryLimit;i++){ if(i>0){If the property connectionRetryLimit is > 0, during each such request, the adapter validates if the EIS connection is active or alive. If the connection is valid, the operation is completed as usual. If the connection is invalid, the adapter invalidates the current managed connection, so that a new managed connection is created (new physical connection). If the connection is created successfully, the outbound operation is completed. Otherwise, an error ResourceException is thrown
Method for validating the connection to EIS ( < AdapterPrefixName>ManagedConnectionFactory.java)public boolean validateManagedConnection(WBIManagedConnection mngConn){ //TODO return true; }