Message queues
General description
It is possible to connect to message queues for:
1. receiving responses for asynchronous tasks;
2. receiving events from agents located in restaurants (agent events).
Connection procedure
Connection to the queue is performed using the long polling method. The aggregator needs to perform a Post request to the address:
POST https://{{serverName}}/wsserverlp/api/v2/aggregators/ListenQueue
If there is a message, you will receive an answer immediately. If there is no message, Whiteserver will hold the connection until a message is received or 20 seconds have passed. Then the aggregator must re-establish the connection.
The request body must specify the queue type.
Request format:
{ "queueType": "enum string" }
Queue Type (queueType) | Description |
---|---|
AllQueues | Listen to all queues |
TaskQueue | Listen to asynchronous task queues (tasks) |
EventQueue | Listen to event queues from agents (agent events) |
Response parsing sequence
1. Check for the presence of an 'error' branch. If it is not there, proceed with parsing successfully. If it exists, parse the error.
2. Check for the presence of a 'responseCommon' branch. If it exists, everything is fine, continue parsing. If it does not exist, then there's an error.
3. In the 'responseCommon' branch, check for the presence of 'asyncCode': 'NoOperations'. If it exists, it means there are no new tasks/events. If it doesn't exist, it means there is a response. Parse further.
4. In the "responseCommon" branch parse "taskType".
4.1. If "taskType" = "Event", then parse the "eventResponse" branch and use the restaurant identifier objectId.
4.2. Otherwise, "taskType" = one of the commands. i.e. parse the "taskResponse" branch.
Response — If there is no data
{ "responseCommon": { "asyncCode": "NoOperations" } }
Response - If a response has been received for a task
Successful response to the task
{ "taskResponse": { ----------task response json--------- }, "responseCommon": { "taskGuid": "guid string", "taskType": "enum string", "objectId": int } }
Response to the task with an error
{ "responseCommon": { "taskGuid": "guid string", "taskType": "enum string", "objectId": int }, "error": { ----------error response json--------- } }
Description of parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
taskResponse | Contents of the answer to the problem | ||
responseCommon | General content for the task (taskType - task type, taskGuid - task identifier, objectId - agent identifier) | ||
error | Error content (for more details, see the relevant section) |
Response - Agent event
{ "eventResponse": { ----------agent event response json--------- }, "responseCommon": { "taskType": "Event", "objectId": int }, "error": { ----------error response json--------- } }
Description of parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
eventResponse | Contents of the message from the agent | ||
responseCommon | General content for the task (taskType - task type, taskGuid - task identifier, objectId - agent identifier) | ||
error | Error content (for more details, see the relevant section) |
Response with error
Example: If there is no authorization, the following will be returned:
{ "error": { "wsError": { "code": "error code string" } } }
Description of parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
error | Error content (for more details, see the relevant section) |