使用neo4j服务器而不是嵌入式模式 [英] Use neo4j server instead of embedded mode

查看:201
本文介绍了使用neo4j服务器而不是嵌入式模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行在Tomcat上运行的Web应用程序,该应用程序使用spring-data以嵌入式模式连接到neo4j图形. 我想使用neo4j服务器而不是嵌入式模式,并且我正在寻找一些帮助来确定如何做到这一点. 我的某些应用程序服务相当困难,并且在一次事务中将dto中多个密码请求的结果合并回发给用户.

I'm working on a webapp running on Tomcat which using spring-data to connect to a neo4j graph in embedded mode. I would like to use neo4j server instead of the embedded mode and I am looking for some help to be sure about how to do that. Some of my application services are quite difficult and combine, in a single transaction, the result of several cypher requests in a dto sent back to the user.

首先,我认为我必须创建一个服务器非托管扩展,并且我应该遵循以下步骤. -使我的webapp具有springMVC和spring安全性,以保持和保护用户会话. -将我所有的交易服务重新组合到特定的jar my-app.jar中 -使用Jax-RS在my-app.jar的每个服务上添加一个REST访问点 -使用spring控制器中的spring restTemplate之类的东西从my-app.jar调用服务

First I thought that I have to create a server unmanaged extension and I think I should follow these following steps. - Keep my webapp with springMVC and spring security to hold and secure users sessions. - Regroup all my transactional services in a specific jar my-app.jar - Use Jax-RS to add a REST access point on each of my service of my-app.jar - use something like spring restTemplate from my spring controller to call services from my-app.jar

第一个问题:这种做事方式是好方法吗? 第二个问题:我的服务层中有很多spring注入.如何保持它们正常工作(如何在服务器扩展中添加依赖项?

First question : is this way of doing things is the good way ? Second question : I have many spring injection in my services layer. How can I keep them working (how can I add dependencies in the server extension ?

然后我发现了graphAware,我想知道是否应该使用它.

Then I discovered graphAware and I wonder if I should use it instead.

最后,我只是读了这篇帖子 http://jexp.de/blog/2014/12/spring-data-neo4j-improving-remoting-performance/,看来我应该使用 SpringCypherRestGraphDatabase(如文章末尾的粗体所示).

And finally I just read this post http://jexp.de/blog/2014/12/spring-data-neo4j-improving-remoting-performance/ and it seems that I should use the SpringCypherRestGraphDatabase (as explain in the bold text at the end of the article).

嗯,我有点迷失了,我很乐意为我的应用程序使用neo4j服务器而不是嵌入式模式提供帮助,该应用程序包含一些复杂的事务.

Well, I'm a little bit lost and I would appreciate any help to use neo4j server instead the embedded mode for my application which contain some complexe transactions.

推荐答案

您在这里有很多选择,并且您的思路正确.

You have a number of options here and you are on the right track with your thinking.

选项1:

如果您的用例是业务逻辑繁重的,并且您的问题表明确实如此,那么采用非托管扩展路线是一种选择.

If your use cases are business-logic-heavy, and your question suggests that they are, going the unmanaged extension route is one option.

基本上,然后,您可以将性能最高的Java API和Cypher结合起来(如果需要)来执行您的用例.顺便说一下,我不会在这里使用SDN,因此您必须手动进行映射,但是确实有任何映射吗?也许您只想针对每个用例执行遍历/Cypher查询.

Essentially, you can then combine the most performant Java API and Cypher (if you wish) to perform your use case. I wouldn't use SDN here by the way, so you have to do your mapping manually, but is there really any mapping? Maybe you just want to execute traversals / Cypher queries for each one of your use cases.

然后,每个用例都公开一个简单的REST API,由运行Spring MVC,Spring Security等所有功能的Spring驱动的应用程序使用.您可以在应用程序的控制器中使用Spring的RestTemplate.

Each use case then exposes a simple REST API, which is consumed by your Spring-powered application running Spring MVC, Spring Security, and all that. You can use the RestTemplate from Spring in your app's Controllers.

要添加所有这些内容,还可以使用GraphAware Framework使用Spring MVC开发非托管扩展".那是我的首选,对您的域/应用一无所知.

To add a twist to all that, you can use the GraphAware Framework to develop the "unmanaged extension" using Spring MVC as well. That would be my preferred option, knowing nothing about your domain/app.

选项2:

按照Michael的建议使用新版本的SDN(v4).这使您可以使用带注释的域对象(Spring MVC,Security等)运行应用程序.操作(CRUD和其他操作)将自动转换为Cypher,并通过导线发送到在服务器模式下运行的Neo4j(无需扩展).然后将结果整理回Java对象.

Use the new version of SDN (v4) as Michael suggests. This allows you to run your application with annotated domain objects, Spring MVC, Security, et al. Operations (CRUD and other) are automatically translated to Cypher and sent across the wire to Neo4j running in server mode (no extensions needed). Results are then marshalled back to Java objects.

我们即将发布SDN v4的里程碑1.不应超过一个星期.也就是说,它仍将是Milestone版本,因此尚未准备好投入生产.预计将于5月(ish)发布GA.

We're about to release Milestone 1 of SDN v4. It shouldn't take more than a week. That said, it is still going to be a Milestone release, thus not ready for production. A GA release is expected in May (ish).

您已经可以自己尝试SDN v4.克隆此仓库: https://github.com/spring-projects/spring-data-neo4j ,请确保您位于4.0分支上,并在其上执行mvn clean install. 这里是一个示例应用程序,它是使用Angular JS和Spring Boot构建的.

You can already try SDN v4 yourself. Clone this repo: https://github.com/spring-projects/spring-data-neo4j, make sure you're on the 4.0 branch, and do an mvn clean install on it. Here's a sample app, built using Angular JS and Spring Boot.

请与反馈/问题/问题取得联系(最好通过graphaware dot com的电子邮件信息获得联系).干杯!

Please do get in touch with feedback / questions / problems (best by email info at graphaware dot com). Cheers!

这篇关于使用neo4j服务器而不是嵌入式模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆