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 #
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 #
Map<String, Object> document = new HashMap<>();
document.put("name", "nina-vkote");
kuzzle.getRealtimeController().publish("my-index", "my-collection", document);
::: ::: tab Kotlin
Arguments #
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 #
val document: Map<String?, Any?> = HashMap<String?, Any?>().apply {
put("name", "nina-vkote")
}
kuzzle.realtimeController.publish("my-index", "my-collection", document)
::: ::::
Edit this page on Github(opens new window)