Skip to content

Commit 158d3f2

Browse files
Example for topic write (#9443)
Co-authored-by: Ivan Blinkov <ivan@ydb.tech>
1 parent 23c9255 commit 158d3f2

File tree

1 file changed

+13
-0
lines changed
  • ydb/docs/ru/core/reference/ydb-sdk

1 file changed

+13
-0
lines changed

ydb/docs/ru/core/reference/ydb-sdk/topic.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,19 @@
846846
847847
{% list tabs %}
848848
849+
- C++
850+
851+
Для записи в топик в транзакции необходимо передать ссылку на объект транзакции в метод `Write` сессии записи:
852+
853+
```c++
854+
auto tableSession = tableClient.GetSession().GetValueSync().GetSession();
855+
auto transaction = tableSession.BeginTransaction().GetValueSync().GetTransaction();
856+
NYdb::NTopic::TWriteMessage writeMessage("message");
857+
858+
topicSession->Write(std::move(writeMessage), transaction);
859+
transaction.Commit().GetValueSync();
860+
```
861+
849862
- Java (sync)
850863
851864
[Пример на GitHub](https://github.com/ydb-platform/ydb-java-examples/blob/develop/ydb-cookbook/src/main/java/tech/ydb/examples/topic/transactions/TransactionWriteSync.java)

0 commit comments

Comments
 (0)