I'm trying to use TransactionEventListener in neo4j. There don't seem to be any lifecycle hooks for plugins, so I figure the only way to do it is to have a plugin procedure do it. However, trying to do that gives me this error:
Neo4jError: Writing in read access mode not allowed. Attempted write to internal graph 1 (system)
The plugin uses write mode, even if I'm not actually writing anything to the database; I'm just registering thatTransactionEventListener, although that could indeed lead to writes later on. Still, I've got Write mode.
Here's my procedure:
@Procedure(name = "setTransactionListener", mode = Mode.WRITE)
public Stream<BuiltInProcedures.NodeResult> setTaxonomy(
@Name("taxonomy") Map<String, Map<String, Object>> taxonomy
var managementService = new DatabaseManagementServiceBuilder(Path.of(".")).build();
var listener = new ValidationTransactionListener(taxonomy);
Best guess is that I'm not supposed to register a transaction listener this way. But if not this way, then how? There don't seem to be any lifecycle hooks that get called when the database starts, so how can I possibly register an TransactionEventListener?
Or is there a way I can give myself permission to do this?
(The issue I'm exploring here is whether it's possible to validate the state of the database from inside a plugin. We've got a taxonomy that describes the structure of our data, but it's currently completely ignored, and because there are so many ways data can enter our database, checking them all is going to be a lot of work. If we can do this from inside the database instead, that would be much more maintainable and more consistent. This is part of a PoC to see if this could work, but I'm totally open to better solutions if they exist.)