Reputation: 215
We have an application that must connect to multiple graph DBs. The database that we want to connect to can be determined in the header of an HTTP request.
I have tried writing an HandlerInterceptorAdapter
and auto wiring the SessionFactory
and then building a Configuration
with the proper URI for the graph I want to connect to. Then I used sessionFactor.getDriver().configure(newConfiguration)
. This worked for the first call, but every subsequent call failed with a message stating the driver was closed.
Is it possible to do such a thing with Spring Data Neo4J?
Upvotes: 0
Views: 73
Reputation: 34
Yes, it's possible to connect to multiple Neo4j databases using Spring Data Neo4j. Create a ThreadLocal bean to manage sessions for different databases based on the HTTP header, ensuring each request gets its dedicated session to prevent driver closure issues.
Upvotes: 0
Reputation: 8262
Spring Data Neo4j has no support for this feature. In general the whole connection and class scanning mechanism will start when your application starts. Altering the configuration during runtime is not intended.
Upvotes: 1