如何使用RestCypherEngine查询设置读取超时

时间:2014-06-20 14:53:25

标签: java neo4j cypher

在我的java应用程序中使用RestCypherEngine进行查询时,我一直在试图弄清楚如何防止Read Socket超时。这是班级......

@Service
public class UserServiceImpl implements UserService {

@Autowired
ThreadPoolTaskExecutor taskExecutor;

@Autowired
RestAPIFacade gd;

@Autowired
RestCypherQueryEngine engine;

@Override
public void addActivityObjectToGraph(List<Activity> activities) {
    taskExecutor.execute(new ProcessActivity(activities));
}

//Runnable to process the activities as they come in..
class ProcessActivity implements Runnable {
    private List<Activity> activities;

    public ProcessActivity() {
    }

    public ProcessActivity(List<Activity> activities) {
        this.activities = activities;
    }

    @Override
    public void run() {
        Map<String, Object> params = new HashMap<>();
        log.info("Processing Activity Collection of size: " + activities.size());

        for (Activity activity : activities) {
            Map<String, Object> props = new HashMap<>();

            props.put("activityid", activity.getActivityID());
            props.put("objecttype", activity.getTargetObjectType());
            props.put("objectid", activity.getTargetObjectID());
            props.put("containertype", activity.getContainerObjectType());
            props.put("containerid", activity.getContainerObjectID());
            props.put("activitytype", activity.getType());
            props.put("userid", activity.getUserID());
            props.put("creationdate", activity.getCreationDate());


            try (Transaction tx = gd.beginTx()) {

                params.put("props", props);
                params.put("userid", activity.getUserID());

engine.query("match (p:Person{userid:{userid}}) create unique (p)-[:created]->(a:Activity{props})", params);

                params.clear();
                tx.success();

            } catch (RestResultException rre) {
                log.info(rre.getLocalizedMessage());
            } catch (CypherExecutionException cee) {
                log.info(cee.getLocalizedMessage());
            }catch(Exception e) {
                    log.info(e.getLocalizedMessage());

            }
        }
    }
}

}

当应用程序刚刚启动时,我从查询中得到了很好的结果但是过了一会儿,我开始收到一堆像这样的异常消息

2014-06-20 09:33:24.070  INFO 12902 [taskExecutor-15] --- c.y.n.services.impl.UserServiceImpl      : java.net.SocketTimeoutException: Read timed out
2014-06-20 09:33:24.446  INFO 12902 [taskExecutor-94] --- c.y.n.services.impl.UserServiceImpl      : java.net.SocketTimeoutException: Read timed out
2014-06-20 09:33:24.501  INFO 12902 [taskExecutor-46] --- c.y.n.services.impl.UserServiceImpl      : java.net.SocketTimeoutException: connect timed out
2014-06-20 09:33:24.512  INFO 12902 [taskExecutor-47] --- c.y.n.services.impl.UserServiceImpl      : java.net.SocketTimeoutException: connect timed out

我在几篇文章中读到,这可以通过将org.neo4j.rest.read_timeout属性设置为100秒来解决,但我不知道如何设置此值。我将设置添加到了我的application.properties文件中(顺便说一下,我正在运行Spring Boot gradle应用程序),但这似乎没有效果。

我在具有30GB RAM的Centos 6服务器上运行Neo4j社区服务器(v2.1.2),我认为即使对于生产级系统也应该足够。我需要做些什么才能摆脱这些错误?

感谢。

0 个答案:

没有答案