Notifications are a publish/subscribe mechanism for registering and receiving events from a GraphDB-SE repository, whenever triples matching a certain graph pattern are inserted or removed. The Sesame API provides such a mechanism, where a RepositoryConnectionListener can be notified of changes to a NotifiyingRepositoryConnection. However, the GraphDB-SE notifications API works at a lower level and uses the internal raw entity IDs for subject, predicate, object instead of Java objects. The benefit of this is that a much higher performance is possible. The downside is that the client must do a separate lookup to get the actual entity values and because of this, the notification mechanism works only when the client is running inside the same JVM as the repository instance. See the next section for the remote notification mechanism.
The subscriber should not rely on any particular order or distinctness of the statement notifications. Duplicate statements might be delivered in response to a graph pattern subscription in an order not even bound to the chronological order of the statements insertion in to the underlying triple store.
The purpose of the notification services is to enable the efficient and timely discovery of newly added RDF data. Therefore, it should be treated as a mechanism for giving the client a hint that certain new data is available and not as an asynchronous SPARQL evaluation engine.
GraphDB's remote notification mechanism provides filtered statement add/remove and transaction begin/end notifications for a local or a remote GraphDB-SE repository. Subscribers for this mechanism use patterns of subject, predicate and object (with wildcards) to filter the statement notifications. JMX is used internally as a transport mechanism.
Registering and deregistering for notifications is achieved through the NotifyingOwlimConnection class, which is located in the owlim-notifications-<version>.jar in the distribution zip file. This class wraps a RepositoryConnection object connected to a GraphDB repository and provides an API to add/remove notification listeners of type RepositoryNotificationsListener. Here is a simple example of the API usage:
The above example works when the GraphDB repository is initialised in the same JVM that runs the example (local repository). If a remote repository is used (e.g. HTTPRepository) the notifying repository connection should be initialized differently:
For remote notifications, where the subscriber and the repository are running in different JVM instances (possibly on different hosts), a JMX remote service should be configured in the repository JVM. This is done by adding the following parameters to the JVM command line:
If the repository is running inside a servlet container, then these parameters must be passed to the JVM that runs the container and GraphDB. For Tomcat, this can be done using the JAVA_OPTS or CATALINA_OPTS environment variable.
where N is the consecutive number of the node we want to configure and PORTN is the port number of that node's JMX service. Cluster workers should also have their com.sun.management.jmxremote.* JVM parameters properly configured. GraphDB-Enterprise cluster master nodes will therefore be controlled and emit notifications using the same JMX port number.
Skip to end of metadata Go to start of metadata