简体   繁体   English

非托管扩展TransactionEventHandler Neo4j

[英]Unmanaged Extension TransactionEventHandler Neo4j

This is also on https://groups.google.com/forum/#!forum/neo4j 这也位于https://groups.google.com/forum/#!forum/neo4j

I'm trying to create an unmanaged extension which puts a message on a queue when a node becomes interesting (eg a relationship of a new type is created) 我正在尝试创建一个非托管扩展,它将在节点变得有趣时(例如,创建新类型的关系)将消息放入队列中

I believe I can do this with a TransactionEventHandler so I have created a class which extends KernelExtensionFactory which has a method (newKernelExtension) which returns a LifeCycle. 我相信我可以使用TransactionEventHandler做到这一点,所以我创建了一个扩展KernelExtensionFactory的类,该类具有一个返回LifeCycle的方法(newKernelExtension)。 My LIfeCycleAdapter then registers the TransactionEventHandler in the start method. 然后,我的LIfeCycleAdapter在start方法中注册TransactionEventHandler。 In my class that implements TransactionEventHandler i have afterCommit, which basically just writes to a text file for the sake of testing. 在实现TransactionEventHandler的类中,我具有afterCommit,该类基本上只是为了测试而写入文本文件。

In conf/neo4j-server.properties I have put the following - 在conf / neo4j-server.properties中,我输入了以下内容-

org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.extensions.events=/db/events

However the server doesnt start. 但是,服务器无法启动。 in console.log I get this - 在console.log中,我得到了-

21:10:57.446 [main] WARN  /db/events - unavailable
   com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
   at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) ~[jersey-server-1.9.j

Now, in my code I haven't declared any paths as I don't need a REST interface to this, I just want it to start when the server starts and then listen for transaction events and then do something with the transaction data (eg write to a file or a messaging queue) 现在,在我的代码中我没有声明任何路径,因为我不需要REST接口,我只希望它在服务器启动时启动,然后侦听事务事件,然后对事务数据做一些事情(例如写入文件或消息队列

So my question is - 所以我的问题是-

Do I need to declare a path? 我需要声明路径吗? Does an unmanaged extension have to be a jaxrs? 非托管扩展必须是jaxrs吗?

You don't need a server extension but just a kernel extension, 您不需要服务器扩展,而只需内核扩展,

so you don't need this config * , which is only for server/REST-extensions: 因此,您不需要此config *该配置仅用于服务器/ REST扩展:

org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.extensions.events=/db/events

Just put your jar in the plugins directory and make sure your have the correct META-INF/services/org.neo4j....KernelExtension file packed in the jar with the fully qualified name of your class as content 只需将jar放在plugins目录中,并确保您具有正确的META-INF / services / org.neo4j .... KernelExtension文件,打包在jar中,并以类的完全限定名称为内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM