SDK
SDK Jvm v1.x
2

publish #

Sends a real-time message to Kuzzle. The message will be broadcasted to all clients with subscriptions matching the index, the collection and the message content.

The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database.

Note: real-time messages are not persisted in the database.

:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<Integer> publish(
  String index, 
  String collection, 
  Map<String, Object> message) 
    throws NotConnectedException, InternalException
Argument Type Description
index
String
Index name
collection
String
Collection name
message
Map<String, Object>
Map representing a JSON payload

Usage #

Copied to clipboard!
Map<String, Object> document = new HashMap<>();
document.put("name", "nina-vkote");
kuzzle.getRealtimeController().publish("my-index", "my-collection", document);

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun publish(index: String, collection: String, message: Map<String?, Any?>): CompletableFuture<Void>
Argument Type Description
index
String
Index name
collection
String
Collection name
message
Map<String?, Any?>
Map representing a JSON payload

Usage #

Copied to clipboard!
val document: Map<String?, Any?> = HashMap<String?, Any?>().apply {
  put("name", "nina-vkote")
}
kuzzle.realtimeController.publish("my-index", "my-collection", document)

::: ::::