SendCommandCommand

Sends a command to an Amazon QLDB ledger.

Instead of interacting directly with this API, we recommend using the QLDB driver or the QLDB shell to execute data transactions on a ledger.

  • If you are working with an AWS SDK, use the QLDB driver. The driver provides a high-level abstraction layer above this QLDB Session data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver  in the Amazon QLDB Developer Guide.

  • If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB shell. The shell is a command line interface that uses the QLDB driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB shell .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { QLDBSessionClient, SendCommandCommand } from "@aws-sdk/client-qldb-session"; // ES Modules import
// const { QLDBSessionClient, SendCommandCommand } = require("@aws-sdk/client-qldb-session"); // CommonJS import
const client = new QLDBSessionClient(config);
const input = { // SendCommandRequest
  SessionToken: "STRING_VALUE",
  StartSession: { // StartSessionRequest
    LedgerName: "STRING_VALUE", // required
  },
  StartTransaction: {},
  EndSession: {},
  CommitTransaction: { // CommitTransactionRequest
    TransactionId: "STRING_VALUE", // required
    CommitDigest: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")     // required
  },
  AbortTransaction: {},
  ExecuteStatement: { // ExecuteStatementRequest
    TransactionId: "STRING_VALUE", // required
    Statement: "STRING_VALUE", // required
    Parameters: [ // StatementParameters
      { // ValueHolder
        IonBinary: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
        IonText: "STRING_VALUE",
      },
    ],
  },
  FetchPage: { // FetchPageRequest
    TransactionId: "STRING_VALUE", // required
    NextPageToken: "STRING_VALUE", // required
  },
};
const command = new SendCommandCommand(input);
const response = await client.send(command);
// { // SendCommandResult
//   StartSession: { // StartSessionResult
//     SessionToken: "STRING_VALUE",
//     TimingInformation: { // TimingInformation
//       ProcessingTimeMilliseconds: Number("long"),
//     },
//   },
//   StartTransaction: { // StartTransactionResult
//     TransactionId: "STRING_VALUE",
//     TimingInformation: {
//       ProcessingTimeMilliseconds: Number("long"),
//     },
//   },
//   EndSession: { // EndSessionResult
//     TimingInformation: {
//       ProcessingTimeMilliseconds: Number("long"),
//     },
//   },
//   CommitTransaction: { // CommitTransactionResult
//     TransactionId: "STRING_VALUE",
//     CommitDigest: new Uint8Array(),
//     TimingInformation: {
//       ProcessingTimeMilliseconds: Number("long"),
//     },
//     ConsumedIOs: { // IOUsage
//       ReadIOs: Number("long"),
//       WriteIOs: Number("long"),
//     },
//   },
//   AbortTransaction: { // AbortTransactionResult
//     TimingInformation: {
//       ProcessingTimeMilliseconds: Number("long"),
//     },
//   },
//   ExecuteStatement: { // ExecuteStatementResult
//     FirstPage: { // Page
//       Values: [ // ValueHolders
//         { // ValueHolder
//           IonBinary: new Uint8Array(),
//           IonText: "STRING_VALUE",
//         },
//       ],
//       NextPageToken: "STRING_VALUE",
//     },
//     TimingInformation: "<TimingInformation>",
//     ConsumedIOs: {
//       ReadIOs: Number("long"),
//       WriteIOs: Number("long"),
//     },
//   },
//   FetchPage: { // FetchPageResult
//     Page: {
//       Values: [
//         {
//           IonBinary: new Uint8Array(),
//           IonText: "STRING_VALUE",
//         },
//       ],
//       NextPageToken: "STRING_VALUE",
//     },
//     TimingInformation: "<TimingInformation>",
//     ConsumedIOs: {
//       ReadIOs: Number("long"),
//       WriteIOs: Number("long"),
//     },
//   },
// };

SendCommandCommand Input

See SendCommandCommandInput for more details

Parameter
Type
Description
AbortTransaction
AbortTransactionRequest | undefined

Command to abort the current transaction.

CommitTransaction
CommitTransactionRequest | undefined

Command to commit the specified transaction.

EndSession
EndSessionRequest | undefined

Command to end the current session.

ExecuteStatement
ExecuteStatementRequest | undefined

Command to execute a statement in the specified transaction.

FetchPage
FetchPageRequest | undefined

Command to fetch a page.

SessionToken
string | undefined

Specifies the session token for the current command. A session token is constant throughout the life of the session.

To obtain a session token, run the StartSession command. This SessionToken is required for every subsequent command that is issued during the current session.

StartSession
StartSessionRequest | undefined

Command to start a new session. A session token is obtained as part of the response.

StartTransaction
StartTransactionRequest | undefined

Command to start a new transaction.

SendCommandCommand Output

See SendCommandCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
AbortTransaction
AbortTransactionResult | undefined

Contains the details of the aborted transaction.

CommitTransaction
CommitTransactionResult | undefined

Contains the details of the committed transaction.

EndSession
EndSessionResult | undefined

Contains the details of the ended session.

ExecuteStatement
ExecuteStatementResult | undefined

Contains the details of the executed statement.

FetchPage
FetchPageResult | undefined

Contains the details of the fetched page.

StartSession
StartSessionResult | undefined

Contains the details of the started session that includes a session token. This SessionToken is required for every subsequent command that is issued during the current session.

StartTransaction
StartTransactionResult | undefined

Contains the details of the started transaction.

Throws

Name
Fault
Details
BadRequestException
client

Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.

CapacityExceededException
server

Returned when the request exceeds the processing capacity of the ledger.

InvalidSessionException
client

Returned if the session doesn't exist anymore because it timed out or expired.

LimitExceededException
client

Returned if a resource limit such as number of active sessions is exceeded.

OccConflictException
client

Returned when a transaction cannot be written to the journal due to a failure in the verification phase of optimistic concurrency control (OCC).

RateExceededException
client

Returned when the rate of requests exceeds the allowed throughput.

QLDBSessionServiceException
Base exception class for all service exceptions from QLDBSession service.