How to implement web services application using OpenRDF Sesame alongside Sesame Server and Workbench

StackOverflow https://stackoverflow.com/questions/16842204

  •  30-05-2022
  •  | 
  •  

Question

I would like to implement some RESTful web services, using Jersey, which access data from a RDF triplestore using SPARQL via the Sesame Java API. At the same time I would like to run a SPARQL endpoint on the same triplestore using the Sesame Server and Workbench web apps. I am a little confused about how best to put these together.

Specifically, should my Jersey app connect to the triplestore "directly" using the Sesame API (while the Sesame server app is doing the same thing) or should it instead interact with the triplestore via the Sesame server's HTTP interface (also using the Sesame API). This seems less efficient since they are on the same machine, but I don't know whether two web apps should use the triplestore simultaneously.

Was it helpful?

Solution

It's not recommended to access the same Sesame store from two different java applications directly. Sesame's SAIL (the database access layer) assumes it has sole control over the resources on disk, having two different JVMs apply two different SAIL objects to the same resources will likely lead to inconsistencies or deadlocks. So you should set things up via HTTP. Granted that this is less efficient, but Sesame has quite a few optimizations (custom binary serializations etc.) in place to speed up HTTP communication, so it should be quite workable.

An alternative is that you extend your Jersey app such that it exposes the (local) Sesame repository you are using with your own implementation of Sesame's REST protocol, including a SPARQL endpoint. If you do that, you can connect to your Sesame store from the Workbench without running it on a Sesame Server.

It's more work of course, but if performance of your own app is a big concern, this might be a good way to go. It's probably not as hard as it sounds since all the functional stuff (SPARQL engine, determining proper formats based on mime-types, etc. etc.) is all supplied by Sesame, you "just" need to tie it together.

But I'd give the first option (talking to a HTTP repository from your Jersey app) a try first, if I were you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top