OCI Autonomous Transaction Processing

The Helidon SE OCI Autonomous Transaction Processing integration provides a reactive API to ATP database in Oracle cloud.

Deprecated

The custom Helidon SE OCI clients documented here are deprecated. It is recommended that you use the OCI Java SDK directly, in particular the Async clients. For more information see:

Experimental

Helidon integration with Oracle Cloud Infrastructure is still experimental and not intended for production use. APIs and features have not yet been fully tested and are subject to change.

Maven Coordinates

To enable OCI Autonomous Transaction Processing add the following dependency to your project’s pom.xml (see Managing Dependencies).

        <dependency>
            <groupId>io.helidon.integrations.oci</groupId>
            <artifactId>helidon-integrations-oci-atp</artifactId>
        </dependency>
Copied

Setting up the Autonomous Transaction Processing

In order to use the OCI Autonomous Transaction Processing integration, the following setup should be made:

Config ociConfig = config.get("oci");

OciAutonomousDbRx ociAutonomousDb = OciAutonomousDbRx.create(ociConfig);
Copied

Current configuration requires ~/.oci/config to be available in the home folder. This configuration file can be downloaded from OCI.

Routing should be added to the WebServer, in our case pointing to /atp:

        WebServer.builder()
                .config(config.get("server"))
                .routing(Routing.builder()
                                .register("/atp", new AtpService(autonomousDbRx, config)))
                .build();
Copied

Additionally, in application.yaml OCI properties should be specified:

oci:
  atp:
    ocid: "<ocid of your ATP database>"
    walletPassword: "<password to encrypt the keys inside the wallet>"
Copied

The exact values are available from OCI console.

OCI ATP

Using the Autonomous Transaction Processing

In the Service we must specify the mapping for operations with the database and their handlers:

@Override
public void update(Routing.Rules rules) {
    rules.get("/wallet", this::generateWallet);
}
Copied

Generate Wallet

To generate wallet file for OCI Autonomous Transaction Processing:

    private void generateWallet(ServerRequest req, ServerResponse res) {
        autonomousDbRx.generateWallet(GenerateAutonomousDatabaseWallet.Request.builder()) 
                .flatMapOptional(ApiOptionalResponse::entity)
                .map(GenerateAutonomousDatabaseWallet.Response::walletArchive) 
                .ifEmpty(() -> LOGGER.severe("Unable to obtain wallet!"))
                .flatMapSingle(this::createDbClient) 
                .flatMap(dbClient -> dbClient.execute(exec -> exec.query("SELECT 'Hello world!!' FROM DUAL")))
                .first()
                .map(dbRow -> dbRow.column(1).as(String.class)) 
                .ifEmpty(() -> res.status(404).send())
                .onError(res::send)
                .forSingle(res::send);
    }
Copied
  • Create the Request using GenerateAutonomousDatabaseWallet.Request.builder()
  • Retrieve 'walletArchive' from the response.
  • Create DBClient using info from 'walletArchive'
  • Read the first column from first row of result.

For complete code, about how to create DBClient using wallet info, please see ATP Reactive Example