8

I am building an application that uses the native neo4j JavaScript driver. I want to make sure that my code will work if we migrate to a causal cluster.

The online documentation doesn't seem to be clear about how to do this: I notice sparse references to things like "bookmarks" and "reading what you have written", etc. But how it all fits together is unclear.

Can someone please provide a synopsis?

Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42
Joel Stevick
  • 1,638
  • 2
  • 16
  • 22

1 Answers1

5

To use causal cluster you will need to change :

1) the url connection : replace bolt://localhost:7687 by bolt+routing://localhost:7687

This will allow your application to make some LB query to the cluster, and be fault tolerant without doing anything else

2) When you open a new session, you should specified what you will do into this session, ie. READ or WRITE. This will help the driver to choose the good server (ie a core or a replica server). Otherwise it assumes you will do some WRITE operations, and the driver will always choose a core server ...

3) because you will be on a cluster env., there is some lag (some secondes) for the propagation of an update inside the cluster. Or sometimes, you need to read your own writes within two sessions. It's where you will need the bookmark functionality.

Documentation is here : https://neo4j.com/docs/developer-manual/current/drivers/

Cheers.

logisima
  • 7,340
  • 1
  • 18
  • 31
  • Thank you this is very helpful, according to the documentation that you referenced above, I would expect to see an access-mode argument for the session() method in the Driver class in https://neo4j.com/docs/api/javascript-driver/current/class/src/v1/driver.js~Driver.html#instance-method-session , what am I missing? – Joel Stevick Feb 10 '17 at 15:22
  • That seems to be referring to v1 of the driver. The latest is v1.1. See here - https://github.com/neo4j/neo4j-javascript-driver/blob/1.1/lib/v1/driver.js#L174 – Mark Needham Feb 10 '17 at 17:48
  • Thank you. That is what I needed! – Joel Stevick Feb 10 '17 at 19:06