How do we generate transaction logs ?

This is how I created Client
def loadClient(graphId: String): Client = {
val typeSerializerRegistry = TypeSerializerRegistry.build.addRegistry(JanusGraphIoRegistry.instance).create
val cluster = Cluster.build()
.addContactPoint(contactUrl)
.port(port.asInstanceOf[Int])
.serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.create()

cluster.connect()
}
def loadClient(graphId: String): Client = {
val typeSerializerRegistry = TypeSerializerRegistry.build.addRegistry(JanusGraphIoRegistry.instance).create
val cluster = Cluster.build()
.addContactPoint(contactUrl)
.port(port.asInstanceOf[Int])
.serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.create()

cluster.connect()
}
This how the query is executed
client.submit(query, statementParameters).all().get()
client.submit(query, statementParameters).all().get()
12 Replies
Aiman
AimanOP6mo ago
@TSC @Committer Any help on this ?
Bo
Bo6mo ago
If you want to work with transaction logs (e.g. recovery), you need to use java
Aiman
AimanOP6mo ago
Yeah Okay, but please can you share something @Bo
porunov
porunov6mo ago
@Aiman Sharief check documentation regarding Transaction Log here: https://docs.janusgraph.org/advanced-topics/transaction-log/
Aiman
AimanOP6mo ago
Can I get any sample code, because the documentation seems unclear to me.
porunov
porunov6mo ago
The documentation provides sample code. I’m not sure what exactly you are looking for as the documentation provides you both samples: - how to register change processors - how to build a transaction which uses your log message bus
Aiman
AimanOP6mo ago
@Oleksandr Porunov My requirement is - whenever a vertex is created / updated a transaction log must be generated which should have the properties created/updated.
porunov
porunov6mo ago
I am not sure if you checked the documentation I posted above but that’s exactly what examples the documentation provides. I.e. any mutation operations (create / update / remove) is tracked by the transaction log. There is also WAL available which tracks everything before transaction is committed or after transaction is committed. Please, check the documentation and let us know if there are any sections which are confusing.
Aiman
AimanOP6mo ago
Since my code has the remote connection configured ; we have access to the client. How would we generate tx log one using the client?
Bo
Bo6mo ago
are you using Java? As I said before, you need to use java
Aiman
AimanOP6mo ago
Yes I'll shift the code from scala to java. @Bo @porunov Is there anything you could help on this?
porunov
porunov6mo ago
The transaction log is processed on the server side and not on the client side. Thus, you would need to create a log processor on your server side (as showed in the documentation). The log processor will be triggered anytime a mutation for that particular log happens. You may potentially have many same log processors listening to the same log on each of your JanusGraph servers or just a single log processor if that’s what you are looking for. You can use JanusGraph in embedded mode to open change processor OR you may send your groovy script using the remote connection. As you are using a remote connection, you may wish to connect to your JanusGraph server and send a groovy script which does exactly what documentation says (i.e. opens a log processor with your custom logic). In case your server is secured against groovy scripts and you cannot send non-gremlin compliant scripts you may want to add your groovy script to the startup of GremlinServer (please, refer to TinkerPop documentation on how to attach your custom scripts to your servers).
Want results from more Discord servers?
Add your server