Reputation: 469
I am using neo4j HTTP API for importing data to neo4j. I know according to this document timeout period can be set globally by setting dbms.rest.transaction.idle_timeout property. However instead of doing this can we set timeout dynamically for transaction when begin the transaction. Please see begin transaction API.
Upvotes: 1
Views: 444
Reputation: 3856
Actually, you can achieve this by using the APOC extension's apoc.cypher.runTimeboxed
method. Check this link https://neo4j.com/labs/apoc/4.1/cypher-execution/cypher-timeboxed/
You can download the JAR file for the APOC library. Then you should put the JAR file under the /plugins
folder then restart your neo4j database.
For every cypher query you executed with HTTP, you can wrap them with a "timeboxed" expression. Check the below codes.
const cql = "MATCH (n)-[e]-() RETURN n,e limit 10";
const timeout = 10000;
const q = `CALL apoc.cypher.runTimeboxed("${cql}", {}, ${timeout})`;
Upvotes: 0
Reputation: 67019
You cannot set the timeout dynamically when you create a transaction.
However, you can dynamically extend the global timeout period for an active transaction by using it to send an empty list of statements to the server, which will restart the clock for the timeout period. See here for the documentation.
Upvotes: 2