How can I have a transaction contains distributedlog operations and table service operations?
- Dominant language
- Java
- Stars
- 2k
- Forks
- 976
- Avg merge
- 6d 15h
- Merged PRs (30d)
- 7
Description
just like below:
```java
DistributedLogManager distributedLogManager = namespace.openLog("stream2");
AsyncLogWriter writer = FutureUtils.result(distributedLogManager.openAsyncLogWriter());
byte[] data = "abdsfdsfdsfdsfasfdsfdsafaser324234243211v23rrcrevrevvtojr3n4ucrn4ru4rqnc".getBytes();
Transaction.begin();
LogRecord record = new LogRecord(System.currentTimeMillis(), data);
Future writeFuture = writer.write(record);
DLSN dlsn= writeFuture.get();
String namespace = "tableservice_namespace";
String tableName = "test";
String key = "progress";
DLSN dlsn = DLSN.InitialDLSN;
StorageClientSettings settings = StorageClientSettingsInstance.SETTINGS;
try (StorageClient client = StorageClientBuilder.newBuilder()
.withSettings(settings)
.withNamespace(namespace)
.build()) {
try (Table table = result(client.openTable(tableName))) {
result(table.put(
Unpooled.wrappedBuffer(key.getBytes(UTF_8)),
Unpooled.wrappedBuffer(dlsn.toString().getBytes(UTF_8))));
System.out.println("Successfully update kv: ('" + key + "', '" + dlsn + "').");
}
} catch (Exception e) {
// log.error("Failed to process commands under namespace '{}'",
// globalFlags.namespace, e);
// spec.console().println("Failed to process stream admin command");
// e.printStackTrace(spec.console());
e.printStackTrace();
}
Transaction.commit();
```
Contributor guide
Assessment
This issue has not been assessed yet.