Custom adapter shutdown if connection problem to resource


I would like to shutdown my custom adapter when there is a connection problem with the resource application. The adapter monitor then should try to restart the adapter automatically after some time. I guess this is the way the commercial adapters work, too.

Which method do I have to call in my code to shutdown my adapter (which implements the Adapter interface)? Or should I throw an exception?

I tried to find references in the list archives and the “Adapter Development Kit User Guide”. Also the following code does (of course) not work:

public void adapterStartup() throws AdapterException
    //other code ...
    if (false == adapterAccess.isConnectTest()) {
        if (!resourcePing()) {	//resourcePing() pings the resource

and returns false, if problem
} //END public void adapterStartup() throws AdapterException

Thanks … Rick

Use this piece of code:
AdapterException e = new AdapterException(…);
throw e;


Thank you for the answer. This code works fine in adapterStartup().
If, however, a fatal AdapterException from within scriptInvoke in an Operation Template is thrown, nothing happens (i.e. I only get an error and errorNotify doument). But I would like to have the adapter to shutdown also in these situations.

To simulate this, I have the following code:
a) in OperationTemplate.scriptInvoke(…):

MyAdapter adapter = (MyAdapter).access.getAdapter();
adapter.checkConnectionProblem(new Exception(“foo”));

b) in MyAdapter.adapterStartup(…):

if (false == adapterAccess.isConnectTest()) resourcePing();

c) in MyAdapter:
public void resourcePing() throws AdapterException{
try {
double ran = Math.random();
if (ran < 0.5d) throw new Exception(Double.toString(ran));
catch (Exception e) {
String text = "resourcePing(): Cannot connect to resource: " + e.toString();
AdapterException ae = new AdapterException(text);
throw ae;

d) in MyAdapter:
public void checkConnectionProblem(Exception anException) throws AdapterException {
//parse Exception and if needed do ping

So: if I get a fatal AdapterExeption in c) when called from b) the adapter shutsdown as desired. However, if a fatal AdapterException is thrown in c) when called from a) via d) then the adapter will not shutdown.

Any idea how I can bring the adapter down from within a OperationTemplate.scriptInvoke()?

Thanks in advance … Rick

PS: I want to use d) to first parse the Exception.toString() to find out, whether it probably has been a connection problem.

your code looks good. What version of the ADK are you using? Any patches installed? Finally, is your adapter multi-threaded by any chance? There have been a few issues with fatal exceptions that got addressed over time.