Skip to content

stream transactions doc #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/Drivers/Java/Reference/Collection/DocumentManipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Retrieves the document with the given \_key from the collection.

Whether or not catch possible thrown exceptions

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -135,6 +139,10 @@ generated automatically.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -190,6 +198,10 @@ generated automatically.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -254,6 +266,10 @@ such a document and no precondition is violated.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -317,6 +333,10 @@ documents in values.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -385,6 +405,10 @@ such a document and no precondition is violated.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down Expand Up @@ -448,6 +472,10 @@ documents in values.
will be returned for the created document. This option can be used to save
some network traffic.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

**Examples**

```Java
Expand Down
4 changes: 4 additions & 0 deletions docs/Drivers/Java/Reference/Database/Queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ a new _ArangoCursor_ instance for the result list.
query statistics, warnings and profiling data will only be available after
the query is finished. The default value is false.

- **streamTransactionId**: `String`

If set, the operation will be executed within the transaction

- **type**: `Class<T>`

The type of the result (POJO class, `VPackSlice`, `String` for JSON, or `Collection`/`List`/`Map`)
Expand Down
81 changes: 81 additions & 0 deletions docs/Drivers/Java/Reference/Database/StreamTransactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Transactions

See [HTTP Interface for Stream Transactions](https://docs.arangodb.com/latest/HTTP/transaction-stream-transaction.html).


## ArangoDatabase.beginStreamTransaction

`ArangoDatabase.beginStreamTransaction(StreamTransactionOptions options) : StreamTransactionEntity`

Begins a server-side transaction and returns information about it.

**Arguments**

- **options**: `StreamTransactionOptions`

transaction options


## ArangoDatabase.getStreamTransaction

`ArangoDatabase.getStreamTransaction(String id) : StreamTransactionEntity`

Gets information about a Stream Transaction.

**Arguments**

- **id**: `String`

transaction id


## ArangoDatabase.commitStreamTransaction

`ArangoDatabase.commitStreamTransaction(String id) : StreamTransactionEntity`

Commits a Stream Transaction.

**Arguments**

- **id**: `String`

transaction id


## ArangoDatabase.abortStreamTransaction

`ArangoDatabase.abortStreamTransaction(String id) : StreamTransactionEntity`

Aborts a Stream Transaction.

**Arguments**

- **id**: `String`

transaction id


## Examples

```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");

StreamTransactionEntity tx1 = db.beginStreamTransaction(
new StreamTransactionOptions().readCollections("collection").writeCollections("collection"));
db.collection("collection")
.insertDocument(new BaseDocument(), new DocumentCreateOptions().streamTransactionId(tx1.getId()));
db.commitStreamTransaction(tx1.getId());
StreamTransactionEntity tx = db.getStreamTransaction(tx1.getId());
assertThat(tx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.committed));

StreamTransactionEntity tx2 = db.beginStreamTransaction(
new StreamTransactionOptions().readCollections("collection").writeCollections("collection"));
final Map<String, Object> bindVars = new HashMap<>();
bindVars.put("@collection", COLLECTION_NAME);
bindVars.put("key", "myKey");
ArangoCursor<BaseDocument> cursor = db
.query("FOR doc IN @@collection FILTER doc._key == @key RETURN doc", bindVars,
new AqlQueryOptions().streamTransactionId(tx2.getId()), BaseDocument.class);
db.abortStreamTransaction(tx2.getId());
```