Napsetern
Napsetern
ATApache TinkerPop
Created by Napsetern on 3/31/2023 in #questions
Custom MutationListener on Transaction
Correct me if I'm wrong but you mean at the end in the status check in the transactionnalQueue ? If so no change noticed. So that means this default code will never trigger the listener a second time ?
graph.traversal().withStrategies(EventStrategy.build().eventQueue(new TransactionalEventQueue(graph)).addListener(new CustomListener()).create())
graph.traversal().withStrategies(EventStrategy.build().eventQueue(new TransactionalEventQueue(graph)).addListener(new CustomListener()).create())
since we never "re add" the transactionnal listener ?
19 replies
ATApache TinkerPop
Created by Napsetern on 3/31/2023 in #questions
Custom MutationListener on Transaction
I had no problem with a non TransactionnalEventQueue (I think it's called DefaultEventQueue) my event are caught and my listener is triggered
19 replies
ATApache TinkerPop
Created by Napsetern on 3/31/2023 in #questions
Custom MutationListener on Transaction
I have tested it with a simple Java App , I tried commit, close and it's no different that just doing a simple addV(), event are catched and added to the event queue but listener is never fired on those event.
19 replies
ATApache TinkerPop
Created by Napsetern on 3/31/2023 in #questions
Custom MutationListener on Transaction
Basically in the TransactionnalEventQueue code below from EventStrategy class I have the feeling that I never go into the else part.
public TransactionalEventQueue(final Graph graph) {
if (!graph.features().graph().supportsTransactions()) {
throw new IllegalStateException(String.format("%s requires the graph to support transactions", EventStrategy.class.getName()));
} else {
graph.tx().addTransactionListener((status) -> {
if (status == Status.COMMIT) {
this.fireEventQueue();
} else {
if (status != Status.ROLLBACK) {
throw new RuntimeException(String.format("The %s is not aware of this status: %s", EventQueue.class.getName(), status));
}

this.resetEventQueue();
}

});
}
}
public TransactionalEventQueue(final Graph graph) {
if (!graph.features().graph().supportsTransactions()) {
throw new IllegalStateException(String.format("%s requires the graph to support transactions", EventStrategy.class.getName()));
} else {
graph.tx().addTransactionListener((status) -> {
if (status == Status.COMMIT) {
this.fireEventQueue();
} else {
if (status != Status.ROLLBACK) {
throw new RuntimeException(String.format("The %s is not aware of this status: %s", EventQueue.class.getName(), status));
}

this.resetEventQueue();
}

});
}
}
19 replies
ATApache TinkerPop
Created by Napsetern on 3/31/2023 in #questions
Custom MutationListener on Transaction
Sure, so I have a JanusGraph where I define in the groovy script g with the EventStrategy and my Custom Listener
globals << [g : graph.traversal().withStrategies(EventStrategy.build().eventQueue(new CustomTransactionnalEventQueue(graph)).addListener(new CustomListener(graph.traversal())).create())]
globals << [g : graph.traversal().withStrategies(EventStrategy.build().eventQueue(new CustomTransactionnalEventQueue(graph)).addListener(new CustomListener(graph.traversal())).create())]
I then start it and see in my logs that both my transactionnal queue and listener are created Then I launch gremlin
./bin/gremlin.sh start
./bin/gremlin.sh start
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin>
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin>
I add a vertex
gremlin> g.addV("test")
==>v[245764288]
gremlin> g.addV("test")
==>v[245764288]
I see that my EventQueue size increased but my listener is not triggered. Since It's a transactionnal queue I try to use g.tx() :
gremlin> g.tx().open()
==>null
gremlin> g.addV("test2")
==>v[614404184]
gremlin> g.tx().commit()
==>null
gremlin> g.tx().close()
==>null
gremlin> g.tx().open()
==>null
gremlin> g.addV("test2")
==>v[614404184]
gremlin> g.tx().commit()
==>null
gremlin> g.tx().close()
==>null
but I see in my logs the same output as a lone g.addV(), my EventQueue gets populated with the event but my event queue is never fired.
19 replies