Last updated Dec 11, 2024

Server side exceptions

Server apps can face issues when executing server side listener method (onStartAppMigration) and stop with an exception. We have seen cases where such server side failures caused the migrations of several apps to expire, as their cloud apps were not aware of server side failure and had not updated their transfer status to a settled state within 14-day time period.

How your cloud app can know about the occurrence of server side exceptions

This feature is available for app migrations using CCMA v3.3.7 and JCMA v1.7.2 onwards.

Your cloud app will be notified with webhook event of type listener-errored (Connect) or a Forge event of type avi:ecosystem.migration:errored:listener (Forge) when the execution of your server side listener method onStartAppMigration has stopped with an uncaught exception. For Forge migrations, the event will also include details such as the type of exception and stack trace to facilitate easier debugging.

What your cloud app can do on the occurrence of server side exceptions (Connect only)

  • Your cloud app can know more about the exception thrown by your server app using the fetch server side error API
  • If your server app stops performing any migration operations for a given transfer on termination of onStartAppMigration, we recommend your cloud app to update the transfer status to a meaningful settled status based on data received so far from your server app.

Best practices for handling exceptions in server apps

When implementing exception handling in your server-side listener method, choose the appropriate approach based on your needs:

This approach is recommended when you encounter fatal errors that should halt the migration process entirely.

1
2
public void onStartAppMigration(AppCloudMigrationGateway gateway, String transferId, MigrationDetailsV1 migrationDetails) {
    try {
        // Your migration logic
    } catch (Exception e) {
        // Do your own logging of the exception to help with debugging
        log.error("Exception occurred in onStartAppMigration", e);
        // Do any cleanup if needed
        throw e; // Rethrow the exception to let the platform know about the exception
    }
}

This allows the app migration platform to automatically emit the listener-errored event to your cloud app.

2. Handle exceptions manually:

This approach is useful when you want to:

  • Record non-fatal errors that shouldn't stop the migration
  • Implement custom error handling logic
1
2
public void onStartAppMigration(AppCloudMigrationGateway gateway, String transferId, MigrationDetailsV1 migrationDetails) {
    try {
        // Your migration logic
    } catch (Exception e) {
        // Use the app data upload mechanism to send exception details to your cloud app
        OutputStream firstDataStream = gateway.createAppData(transferId);
        firstDataStream.write(e.toString().getBytes());
        firstDataStream.close();

        // Don't rethrow the exception here
    }
}

Rate this page: