问题
How to handle multiple session in a single procedure for sample sudo code is presented below?
I tried the same code below but for some reason it doesn't work in as plugin, with the neo4j/plugin...really don't know what happens. [BUT WORKS WELL WITH IN ECLIPSE]
@Procedure("test.begin") public void begin() throws InterruptedException { Driver driver = GraphDatabase.driver("bolt://localhost/", Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig()); Session session = driver.session(); System.out.println("............started"); String query =""; if (true) { try (Transaction tx = session.beginTransaction()) { int count = 10000; for (int i = 0; i < count; i++) { Thread.sleep(1); // some conversion query = "create(n:Person{name:'" + i + "'})"; tx.run(query); } System.out.println("first innerloop"); tx.success(); } } if (true) { try (Transaction tx = session.beginTransaction()) { int count = 10000; for (int p = 0; p < count; p++) { Thread.sleep(1); query = "create(n:Person{name:'" + p + "'})";; tx.run(query); } System.out.println("second innerloop"); tx.success(); } } if (true) { try (Transaction tx = session.beginTransaction()) { int count = 70000; while (count > 0) { /// here this has 1million records for (int j = 0; j < count; j++) { Thread.sleep(2); query = "create(n:Person{name:'" + j + "'})";; tx.run(query); } System.out.println("third innerloop"); count--; } tx.success(); } } session.close(); driver.close(); }
来源:https://stackoverflow.com/questions/39480552/how-to-use-neo4j-bolt-session-transaction-in-a-procedure-as-plugin-for-neo4j-ser