Constructor #
This is the main entry point to communicate with Kuzzle.
Each instance represent a connection to Kuzzle with specific options.
Signature #
Kuzzle(String host)
Kuzzle(String host, io.kuzzle.sdk.Options options)Arguments #
| Argument | Type | Description | Required |
|---|---|---|---|
host | String | The target Kuzzle host | yes |
options | io.kuzzle.sdk.Options | Kuzzle connection configuration | yes |
host #
The Kuzzle host to connect to.
Can be a hostname or an IP address.
options #
| Option | Type | Description | Default | Required |
|---|---|---|---|---|
autoQueue | boolean | Automatically queue all requests during offline mode | false | no |
autoReconnect | boolean | Automatically reconnect after a connection loss | true | no |
autoReplay | boolean | Automatically replay queued requests on a reconnected event | false | no |
autoResubscribe | boolean | Automatically renew all subscriptions on a reconnected event | true | no |
offlineMode | Mode | Offline mode configuration. MANUAL or AUTO | MANUAL | no |
queueTTL | int | Time a queued request is kept during offline mode, in milliseconds | 120000 | no |
queueMaxSize | int | Number of maximum requests kept during offline mode | 500 | no |
replayInterval | Duration | Delay between each replayed requests, in milliseconds | 10 | no |
reconnectionDelay | Duration | number of milliseconds between reconnection attempts | 1000 | no |
sslConnection | boolean | Switch Kuzzle connection to SSL mode | false | no |
volatile | VolatileData | Common volatile data, will be sent to all future requests | - | no |
Notes:
- if
queueTTLis set to0, requests are kept indefinitely - The offline buffer acts like a first-in first-out (FIFO) queue, meaning that if the
queueMaxSizelimit is reached, older requests are discarded to make room for new requests - if
queueMaxSizeis set to0, an unlimited number of requests is kept until the buffer is flushed - multiple methods allow passing specific
volatiledata. Thesevolatiledata will be merged with the global Kuzzlevolatileobject when sending the request, with the request specificvolatiletaking priority over the global ones.
Getter & Setter #
The properties can be writable.
For example, you can read the volatile property via getVolatile() and set it via setVolatile().
| Property name | Type | Description | Availability |
|---|---|---|---|
autoReplay | boolean | Automatically replay queued requests on a reconnected event | Set |
jwt | String | Token used in requests for authentication. | Get |
volatile | String | Common volatile data in JSON format, will be sent to all future requests | Get/Set |
Return #
A io.kuzzle.sdk.Kuzzle instance.
Usage #
Options options = new Options();
options.setAutoResubscribe(false);
WebSocket ws = new WebSocket("kuzzle");
Kuzzle kuzzle = new Kuzzle(ws, options);