GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • V15 Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing docs.voltdb.com — B.3. Invoking Stored Procedures Asynchronously

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • Current docs ▶
  • VoltDB V15
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
B.3. Invoking Stored Procedures Asynchronously

Upgrade Guide

  • Preface▶
    • 1. Structure of This Book
    • 2. Related Documents
  • 1. Software Releases and Long-Term Support (LTS)▶
    • 1.1. The Software Release Schedule
    • 1.2. Staying Current
  • 2. The Software Upgrade Process▶
    • 2.1. Preparing for the Upgrade
    • 2.2. Upgrading Volt Databases on Managed Servers
      • 2.2.1. Upgrading the VoltDB Software
      • 2.2.2. Upgrading VoltDB Using Save and Restore
      • 2.2.3. Performing an In-Service Upgrade of a Single Cluster
      • 2.2.4. Performing an Online Upgrade Using Multiple XDCR Clusters
    • 2.3. Upgrading Volt in Kubernetes
      • 2.3.1. Updating Your Helm Repository
      • 2.3.2. Updating the Custom Resource Definition (CRD)
      • 2.3.3. Upgrading the VoltDB Operator and Software
      • 2.3.4. Using In-Service Upgrade to Update the VoltDB Software
      • 2.3.5. Updating VoltDB for XDCR Clusters
  • 3. Upgrading to Volt Active Data V8▶
    • 3.1. What's New in Volt V8.0
    • 3.2. Special Considerations for Existing Customers
  • 4. Upgrading to Volt Active Data V9▶
    • 4.1. What's New in Volt V9.0
    • 4.2. Special Considerations for Existing Customers
  • 5. Upgrading to Volt Active Data V10▶
    • 5.1. What's New in Volt V10.0
    • 5.2. Special Considerations for Existing Customers
  • 6. Upgrading to Volt Active Data V11▶
    • 6.1. What's New in Volt V11.0
    • 6.2. Special Considerations for Existing Customers
  • 7. Upgrading to Volt Active Data V12▶
    • 7.1. What's New in Volt V12.0
    • 7.2. Special Considerations for Existing Customers
  • 8. Upgrading to Volt Active Data V13▶
    • 8.1. What's New in Volt V13
    • 8.2. Special Considerations for Existing Customers
  • 9. Upgrading to Volt Active Data V14▶
    • 9.1. What's New in Volt Active Data V14
    • 9.2. Special Considerations for Existing Customers
  • 10. Upgrading to Volt Active Data V15▶
    • 10.1. What's New in Volt Active Data V15
    • 10.2. Special Considerations for Existing Customers
  • A. Configuration File (deployment.xml)▶
    • A.1. Understanding XML Syntax
    • A.2. The Structure of the XML Configuration File
  • B. Using the Original VoltDB Client Interface▶
    • B.1. Connecting to the VoltDB Database
      • B.1.1. Connecting to Multiple Servers
      • B.1.2. Using the Auto-Connecting Client
    • B.2. Invoking Stored Procedures
    • B.3. Invoking Stored Procedures Asynchronously
    • B.4. Closing the Connection
    • B.5. Handling Errors
      • B.5.1. Interpreting Execution Errors
      • B.5.2. Handling Timeouts
      • B.5.3. Writing a Status Listener to Interpret Other Errors

B.3. Invoking Stored Procedures Asynchronously

Calling stored procedures synchronously simplifies the program logic because your client application waits for the procedure to complete before continuing. However, for high performance applications looking to maximize throughput, it is better to queue stored procedure invocations asynchronously.

Asynchronous Invocation

To invoke stored procedures asynchronously, use the callProcedure() method with an additional first argument, a callback that will be notified when the procedure completes (or an error occurs). For example, to invoke a NewCustomer() stored procedure asynchronously, the call to callProcedure() might look like the following:

client.callProcedure(new MyCallback(),
                     "NewCustomer",
                     firstname,
                     lastname,
                     custID};

The following are other important points to note when making asynchronous invocations of stored procedures:

  • Asynchronous calls to callProcedure() return control to the calling application as soon as the procedure call is queued.

  • If the database server queue is full, callProcedure() will block until it is able to queue the procedure call. This is a condition known as backpressure. This situation does not normally happen unless the database cluster is not scaled sufficiently for the workload or there are abnormal spikes in the workload. See Section B.5.3, “Writing a Status Listener to Interpret Other Errors” for more information.

  • Once the procedure is queued, any subsequent errors (such as an exception in the stored procedure itself or loss of connection to the database) are returned as error conditions to the callback procedure.

Callback Implementation

The callback procedure (MyCallback() in this example) is invoked after the stored procedure completes on the server. The following is an example of a callback procedure implementation:

static class MyCallback implements ProcedureCallback {
  @Override
  public void clientCallback(ClientResponse clientResponse) {
    if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
       System.err.println(clientResponse.getStatusString());
   } else {
       myEvaluateResultsProc(clientResponse.getResults());
    }
  }
}

The callback procedure is passed the same ClientResponse structure that is returned in a synchronous invocation. ClientResponse contains information about the results of execution. In particular, the methods getStatus() and getResults() let your callback procedure determine whether the stored procedure was successful and evaluate the results of the procedure.

The VoltDB Java client is single threaded, so callback procedures are processed one at a time. Consequently, it is a good practice to keep processing in the callback to a minimum, returning control to the main thread as soon as possible. If more complex processing is required by the callback, creating a separate thread pool and spawning worker methods on a separate thread from within the asynchronous callback is recommended.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.