[英]Neo4j DB - client connection
I've got a question about getting control of query 'timeout'. 我有一个关于控制查询“超时”的问题。 What i want to achive is that i could control 'query timeout' - i want to set it let's say for 3 seconds and if query will take longer, i'll get an exception/whatever.
我要实现的是我可以控制“查询超时”-我想设置它为3秒钟,如果查询需要更长的时间,我将得到一个异常/无论如何。
So far i was trying countless ways, even with overriding some api's to get to the Client within RestRequest to set it there... but i had no transaction controll. 到目前为止,我什至尝试了无数种方法,即使重写了一些API以便在RestRequest中到达客户端以在此处进行设置...但是我没有事务控制。
I'm not posting any versions of components i've used/tried already, becouse it's not a big deal to change it. 我不会发布已经使用过或尝试过的组件的任何版本,因为更改它并不大。 The only 1 restriction is java version 6.
唯一的限制是Java版本6。
Please, post some advices / approaches that i could use... becouse im out of ideas. 请发表一些我可以使用的建议/方法...因为我出于想法。
Cheers! 干杯!
You can configure the transaction timeout in conf/neo4j-server.properties
with this setting: 您可以使用以下设置在
conf/neo4j-server.properties
配置事务超时:
org.neo4j.server.transaction.timeout=NUMBER_OF_SECONDS_HERE
More info available in the docs here 此处的文档中提供了更多信息
Edit 编辑
You can control timeout on a per query basis by enabling execution guard on the Neo4j server and adding a max-execution-time
header to your request: 您可以通过在Neo4j服务器上启用执行保护并将
max-execution-time
标头添加到您的请求中来控制每个查询的超时:
In conf/neo4j-server.properties
set: 在
conf/neo4j-server.properties
设置:
org.neo4j.server.webserver.limit.executiontime=MAX_POSSIBLE_MS_HERE
In conf/neo4j.properties
set: 在
conf/neo4j.properties
设置:
execution_guard_enabled=true
Then add header max-execution-time=100
and the timeout for that query only will be 100ms. 然后添加标头
max-execution-time=100
并且该查询的超时仅为100ms。
More information available here and here 此处和此处提供更多信息
I just tested this against both the legacy Cypher HTTP endpoint and the transactional Cypher endpoint for Neo4j 2.2.5. 我刚刚针对Neo4j 2.2.5的传统Cypher HTTP端点和事务性Cypher端点进行了测试。
From what I tested (neo4j 2.2.2) it seems that you will need to set both of the following: 根据我的测试(neo4j 2.2.2),您似乎需要设置以下两项:
in ./conf/neo4j.properties
: 在
./conf/neo4j.properties
:
execution_guard_enabled=true
and in ./conf/neo4j-server.properties
: 并在
./conf/neo4j-server.properties
:
org.neo4j.server.webserver.limit.executiontime={timeout_in_seconds}
(note: this number is in seconds, not milliseconds) (注意:此数字以秒为单位,而不是毫秒)
before a query specific timeout, added to the header of the request, will work. 在添加到请求标头中的查询特定超时之前,此方法将起作用。
`max-execution-time={timeout_in_milliseconds}`
Neo4j will use whichever timeout is shorter, so specify a large timeout in the property file. Neo4j将使用较短的超时时间,因此请在属性文件中指定较大的超时时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.