-
Notifications
You must be signed in to change notification settings - Fork 224
/
com.azure.messaging.servicebus.ServiceBusTransactionContext.yml
39 lines (39 loc) · 4.13 KB
/
com.azure.messaging.servicebus.ServiceBusTransactionContext.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
### YamlMime:JavaType
uid: "com.azure.messaging.servicebus.ServiceBusTransactionContext"
fullName: "com.azure.messaging.servicebus.ServiceBusTransactionContext"
name: "ServiceBusTransactionContext"
nameWithType: "ServiceBusTransactionContext"
summary: "Represents transaction in service."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public final class **ServiceBusTransactionContext**"
methods:
- uid: "com.azure.messaging.servicebus.ServiceBusTransactionContext.getTransactionId()"
fullName: "com.azure.messaging.servicebus.ServiceBusTransactionContext.getTransactionId()"
name: "getTransactionId()"
nameWithType: "ServiceBusTransactionContext.getTransactionId()"
summary: "Gets the transaction id."
syntax: "public ByteBuffer getTransactionId()"
desc: "Gets the transaction id."
returns:
description: "transaction ID"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html\">ByteBuffer</a>"
type: "class"
desc: "Represents transaction in service. This object just contains transaction id. Transaction management operations like create transaction, rollback, and commit operation need to be done using the sender or receiver clients.\n\nA transaction times out after 2 minutes. The transaction timer starts when the first operation in the transaction starts.\n\n**Creating and using a transaction**\n\n```java\n// This mono creates a transaction and caches the output value, so we can associate operations with the\n // transaction. It does not cache the value if it is an error or completes with no items, effectively retrying\n // the operation.\n Mono<ServiceBusTransactionContext> transactionContext = asyncReceiver.createTransaction()\n .cache(value -> Duration.ofMillis(Long.MAX_VALUE),\n error -> Duration.ZERO,\n () -> Duration.ZERO);\n\n // Dispose of the disposable to cancel the operation.\n Disposable disposable = transactionContext.flatMap(transaction -> {\n // Process messages and associate operations with the transaction.\n Mono<Void> operations = Mono.when(\n asyncReceiver.receiveDeferredMessage(sequenceNumber).flatMap(message ->\n asyncReceiver.complete(message, new CompleteOptions().setTransactionContext(transaction))),\n asyncReceiver.abandon(receivedMessage, new AbandonOptions().setTransactionContext(transaction)));\n\n // Finally, either commit or rollback the transaction once all the operations are associated with it.\n return operations.then(asyncReceiver.commitTransaction(transaction));\n }).subscribe(unused -> {\n }, error -> {\n System.err.println(\"Error occurred processing transaction: \" + error);\n }, () -> {\n System.out.println(\"Completed transaction\");\n });\n```"
metadata: {}
package: "com.azure.messaging.servicebus"
artifact: com.azure:azure-messaging-servicebus:7.17.1