{
"type": "register",
"address": "mesh.user.updated"
}
In Gentics Mesh events can be used to exchange information in between clients and to inform clients about changes in the CMS.
Typical use cases for event handling:
Exchange data in between client applications (e.g. Chat)
Real time reload if data via mesh.node.updated
changes.
Client-Side cache purging if data is updated, created, deleted.
Hooking external hardware sensors into your front-end.
Events in Gentics Mesh can be triggered by various action. Updating a user for example will trigger the mesh.user.updated
event. Events for specific actions can be received by registering on the event address (e.g. mesh.user.updated
or mesh.user.deleted
).
A websocket endpoint is used to deliver event messages to clients which register on the event addresses.
Typical workflow:
Authenticate HTTP client
Connect client to websocket
Send message on websocket to register on specific event addresses
Receive events messages
Regularly send ping messages.
The
endpoint allows clients to access the eventbus. This is useful if you want to react on specific events./api/v2/eventbus
The endpoint is SockJS compliant. It is also possible to access the websocket directly via:
./api/v2/eventbus/websocket
JavaScript projects can use the vertx3-eventbus-client library to connect to the eventbus bridge.
Once the websocket has been opened you can send a text frame to Gentics Mesh that contains the information to which address you want to register to. Once registered the client will receive the published messaged on that address.
{
"type": "register",
"address": "mesh.user.updated"
}
If you want to unregister for specific events you can send a message of type unregister
.
{
"type": "unregister",
"address": "mesh.user.updated"
}
You can publish a message which will be received by all recipients which has registered on to the used address. The published message will be delivered to each of the recipients.
{
"type": "publish",
"address": "custom.event",
"body": "someText"
}
Sending a message is different from publishing. When sending a message it will only be received by one randomly selected recipient.
{
"type": "publish",
"address": "custom.event",
"body": "someText"
}
The eventbus bridge requires the client to send a regular ping
message. The timeout for a ping message is currently set to 10
seconds. The websocket will automatically be terminated if no ping message has been received in this interval.
Handling the ping message is essential. The eventbus bridge will not work properly without handling ping messages. |
{
"type": "ping"
}
The following list contains all event addresses with examples which Gentics Mesh exposes.
Emitted once a version purge job starts
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demo",
"status" : "RUNNING"
}
Emitted once a version purge job finishes successully or failed
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demo",
"status" : "RUNNING"
}
Emitted once a schema migration starts.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING",
"fromVersion" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"toVersion" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "2",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted once the migration finishes successful or failed.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING",
"fromVersion" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"toVersion" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "2",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted once a schema has been assigned to a branch.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"schema" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"status" : "COMPLETED"
}
Emitted once a schema has been unassigned from a branch.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"schema" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"status" : "COMPLETED"
}
Emitted once a microschema gets assigned to a branch.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"schema" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"status" : "COMPLETED"
}
Emitted once a microschema gets unassigned from a branch.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"schema" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"status" : "COMPLETED"
}
Emitted when a microschema migration starts.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING",
"fromVersion" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"toVersion" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "2",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a microschema migration finishes.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING",
"fromVersion" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"toVersion" : {
"name" : "vcard",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "2",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a branch migration job starts.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING"
}
Emitted when a branch migration job finishes.
{
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"uuid" : "2619185de0db4a5399185de0dbda53da",
"status" : "RUNNING"
}
Emitted once the Gentics Mesh instance is fully started and ready to accept requests.
Event which will trigger job processing.
Emitted when a node joins the cluster.
Emitted when a node joined the cluster.
Emitted when a node is leaving the cluster.
Emitted when a cluster node left the cluster.
Emitted when the database status changes. (e.g. offline, online, backup, syncing)
Event, which is emitted regularly to check whether local eventbus works
Event, which is emitted regularly to check whether clustered eventbus works
Event which will clear the permission stores.
Event which will clear the path stores.
Event which will clear the internal caches.
Emitted when a user was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "joedoe"
}
Emitted when a user was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "joedoe"
}
Emitted when a user was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "joedoe"
}
Emitted when a group was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "guests"
}
Emitted when a group was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "guests"
}
Emitted when a group was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "guests"
}
Emitted when a user was assigned to a group.
{
"group" : {
"name" : "guests",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"user" : {
"firstName" : "Joe",
"lastName" : "Doe",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a user was unassigned from a group.
{
"group" : {
"name" : "guests",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"user" : {
"firstName" : "Joe",
"lastName" : "Doe",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a role was assigned to a group.
{
"group" : {
"name" : "guests",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"role" : {
"name" : "translator",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a role was unassigned from a group.
{
"group" : {
"name" : "guests",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"role" : {
"name" : "translator",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a role was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "translator"
}
Emitted when a role was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "translator"
}
Emitted when a role was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "translator"
}
Emitted when the role permissions were changed.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "editors",
"type" : "GROUP",
"role" : {
"name" : "translator",
"uuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
Emitted when a tag was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "red",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"tagFamily" : {
"name" : "colors",
"uuid" : "cd6b4f2851814773ab4f28518137735f"
}
}
Emitted when a tag was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "red",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"tagFamily" : {
"name" : "colors",
"uuid" : "cd6b4f2851814773ab4f28518137735f"
}
}
Emitted when a tag was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "red",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"tagFamily" : {
"name" : "colors",
"uuid" : "cd6b4f2851814773ab4f28518137735f"
}
}
Emitted when a tag family was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "colors",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a tag family was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "colors",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a tag family was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "colors",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a project was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demo"
}
Emitted when a project was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demo"
}
Emitted when a project was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demo"
}
Emitted when a schema was assigned to a project.
Emitted when a schema was unassigned from a project.
Emitted when a microschema was assigned to a projec.t
Emitted when a microschema was unassigned from a project.
Emitted when the latest branch reference of a project was updated.
Emitted when a node was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branchUuid" : "cd6b4f2851814773ab4f28518137735f"
}
Emitted when a node was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branchUuid" : "cd6b4f2851814773ab4f28518137735f"
}
Emitted when a node was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branchUuid" : "cd6b4f2851814773ab4f28518137735f"
}
Emitted when a node was tagged.
{
"tag" : {
"name" : "red",
"uuid" : "e5861ba26b914b21861ba26b91ab211a",
"tagFamily" : "colors"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
}
}
Emitted when a node was untagged.
{
"tag" : {
"name" : "red",
"uuid" : "e5861ba26b914b21861ba26b91ab211a",
"tagFamily" : "colors"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
}
}
Emitted whena a node or node content was published.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"type" : "PUBLISHED",
"branchUuid" : "cd6b4f2851814773ab4f28518137735f",
"languageTag" : "en"
}
Emitted when a node or node content was unpublished.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"type" : "PUBLISHED",
"branchUuid" : "cd6b4f2851814773ab4f28518137735f",
"languageTag" : "en"
}
Emitted when a node was moved.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branchUuid" : "cd6b4f2851814773ab4f28518137735f",
"schema" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
},
"target" : {
"projectName" : "demo",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"schema" : {
"name" : "folder",
"uuid" : "cd6b4f2851814773ab4f28518137735f",
"version" : "1",
"versionUuid" : "d84a6f054a3f4ed68a6f054a3f1ed635"
}
}
}
Emitted when a content of a node was deleted. (e.g. English language was deleted)
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"type" : "PUBLISHED",
"branchUuid" : "cd6b4f2851814773ab4f28518137735f",
"languageTag" : "en"
}
Emitted when a content of a node was created. (e.g. English translation was added)
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"type" : "PUBLISHED",
"branchUuid" : "cd6b4f2851814773ab4f28518137735f",
"languageTag" : "en"
}
Emitted when a referencing node gets indirectly updated. (e.g. via deleting a node in the node list of the referenced node.)
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branchUuid" : "cd6b4f2851814773ab4f28518137735f"
}
Emitted when a schema was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "content"
}
Emitted when a schema was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "content"
}
Emitted when a schema was deleted
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "content"
}
Emitted when a microschema was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "vcard"
}
Emitted when a microschema was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "vcard"
}
Emitted when a microschema was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "vcard"
}
Emitted when a branch was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demoV1",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a branch was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demoV1",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a branch was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da",
"name" : "demoV1",
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
}
}
Emitted when a branch was tagged.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"tag" : {
"name" : "red",
"uuid" : "e5861ba26b914b21861ba26b91ab211a",
"tagFamily" : "colors"
}
}
Emitted when a branch was untagged.
{
"project" : {
"name" : "demo",
"uuid" : "ec2f5106764c4d94af5106764ccd948a"
},
"branch" : {
"name" : "demoV1",
"uuid" : "b12272150db4490ea272150db4190e72"
},
"tag" : {
"name" : "red",
"uuid" : "e5861ba26b914b21861ba26b91ab211a",
"tagFamily" : "colors"
}
}
Emitted when a job was created.
{
"uuid" : "2619185de0db4a5399185de0dbda53da"
}
Emitted when a job was updated.
{
"uuid" : "2619185de0db4a5399185de0dbda53da"
}
Emitted when a job was deleted.
{
"uuid" : "2619185de0db4a5399185de0dbda53da"
}
Event address which can be used to trigger the sync process.
Emitted when the index sync process starts.
Emitted when the index sync process finishes.
Event address which will trigger a index clear.
Emitted when the index clear process starts.
Emitted when the index clear process finishes.
Event address which will trigger an index check.
Emitted when the index check process starts.
Emitted when the index check process finishes.
Emitted when the search interation process has been working and is now in idle.
When emitted, this event will be answered with the current idle status.
Event which will cause all pending Elasticsearch requests to be sent.
Event which will cause all search indices to be refreshed, so that changes can be queried.
Emitted once the backup process starts.
Emitted once the backup process finishes.
Emitted once the restore process starts.
Emitted once the restore process finishes.
Emitted once the graph database export process starts.
Emitted once the graph database export process finishes
Emitted once the graph database import process starts.
Emitted once the graph database import process finishes.
Emitted once the repair operation is started.
Emitted once the repair operation finishes.
Emitted once a plugin is being deployed.
Emitted once a plugin has been pre-registered.
Emitted once a plugin has been registered.
Emitted once a plugin has been deployed.
Emitted when a plugin deployment fails.
Emitted once a plugin is being undeployed.
Emitted once a plugin has been undeployed.
Emitted when a S3 binary field was created.
Emitted when a S3 binary field gets deleted.
Emitted when the metadata of a S3 binary field is extracted.
Event will cause requests to the binary check service for binary fields which are marked as POSTPONED
It is also possible to register and send custom events. The address of those events must start with custom.
.
Custom events can be used to exchange events in between connected clients.
The eventbus provides a great way to utilize data of your IoT devices in your frontend application. The following example shows how the Arduino compatible ESP8266 WIFI enabled microcontroller can utilize the Gentics Mesh eventbus.
The shown sketch utilizes the arduinoWebSockets library.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsClient.h>
#include <Hash.h>
ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
#define USE_SERIAL Serial1
const char* ssid = "Demo";
const char* password = "12345678";
const byte interruptPin = 13; // D7 on Wemos D1 Mini
volatile byte interruptCounter = 0;
int numberOfInterrupts = 0;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Set the connection details to the Gentics Mesh Server
webSocket.begin("1.2.3.4", 8080, "/api/v2/eventbus/websocket");
webSocket.setReconnectInterval(2000);
// Register the interrupt pin
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, RISING);
}
// Interrupt method which will just count up
void handleInterrupt() {
interruptCounter++;
}
void loop() {
// Check whether the connection needs to be re-established
webSocket.loop();
// Check whether an interrupt has happend and send an event if needed
if (interruptCounter > 0) {
Serial.println("Detected interrupt");
webSocket.sendTXT("{\"type\":\"publish\",\"address\":\"custom.event\",\"body\":\"someText\"}");
// Reset the interrupt counter to get ready for the next event
interruptCounter = 0;
}
delay(100);
// Send a ping to prevent the server to disconnect the connection
webSocket.sendTXT("{\"type\":\"ping\"}");
}
In this example the Pin 13 (D7) on the ESP8266 will be used to trigger an event.
Gentics Mesh does currently not support Webhooks to register to events. |