PrivMX DOCS
Java

KVDB Events

Listening for events related to KVDBs and updating your app's state accordingly will allow you to build e.g., instant mapping features.

Types of Events

The lists below outline all the event types available in KVDBs and entries in PrivMX.

KVDB events:

  • kvdbCreated - triggers when a new KVDB is created in your Context
  • kvdbDeleted - triggers when a KVDB is deleted from your Context
  • kvdbUpdated - triggers when a KVDB is updated
  • kvdbStatsChanged - triggers when an entry is created to a KVDB or an entry has been deleted

Entries events:

  • kvdbNewEntry - triggers when an entry was created in a KVDB
  • kvdbEntryDeleted triggers when an entry was deleted from a KVDB
  • kvdbEntryUpdated - triggers when an entry was updated

Handling KVDB and Entries Events

Before receiving Events, your application has to start an event loop and subscribe to specific events in the given scope. Afterwards you can setup a listener.

Here is an example how to do it in your own project:

String kvdbCallbackID = "KVDB_CALLBACK_ID";
String entryCallbackID = "ENTRY_CALLBACK_ID";
String kvdbID = "KVDB_ID";

// Starting the Event Loop
endpointContainer.startListening();

endpointSession.registerManyCallbacks(

        // Handling KVDB Events
        new CallbackRegistration<>(
                kvdbCallbackID,
                EventType.KvdbStatsChangedEvent(
                        KvdbEventSelectorType.CONTEXT_ID,
                        contextId
                ),
                kvdbStats -> {
                    System.out.println(kvdbStats.lastEntryDate);
                }
        ),

        // Handling KVDB Entry Events
        new CallbackRegistration<>(
                entryCallbackID,
                EventType.KvdbNewEntryEvent(
                        KvdbEventSelectorType.KVDB_ID,
                        kvdbID
                ),
                newEntry -> {
                    System.out.println(newEntry.info.key);
                }
        )
);

endpointSession.unregisterCallbacks(kvdbCallbackID, entryCallbackID);

We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.

PrivMX Endpoint Java v2.6

This package is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however

On this page

KVDB Events | PrivMX Docs