c# - Transaction on Graph Cosmos DB -


i have 2 queries in gremlin first 1 adding vertex, , second 1 adding edge between added vertex , existed vertex in graph.

string query1 = $"g.addv('session').property('id','{session_id}').property('initialstate', 'start')"; string query2 = $"g.v('{session_id}').adde('belongs').to(g.v('{userid}'))"; 

as wrote program in c#, first idea sure both of above commands run or neither of them, using transactionscope in c#. however, not solved problem not on cosmos db. question how can these commands in transaction on graph cosmos db in c#?.

is there technique resolve in gremlin? graph.tx().commit() works on cosmos db?

// in transaction scope idocumentquery<dynamic> query = database.client.creategremlinquery<dynamic>(database.graph, query1); query.executenextasync().result;  query = database.client.creategremlinquery<dynamic>(database.graph, query2); query.executenextasync().result; 

unfortunately, cosmosdb not have support transactions when executing gremlin command.

in case, recommend using @ least session consistency level if aren't already. guarantee read writes across multiple gremlin commands executed within same session. default, documentclient assumes consistency level target document collection configured with.

beyond this, current support gremlin commands in sdk doesn't provide other techniques approximate transactions. there other options available if choose use cosmos db sql commands or stored procs, prevent using gremlin queries operate on data.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -