You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/concept-client-protocols.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,47 @@ As you likely noticed in the earlier PubSub WebSocket client description, a clie
86
86
|`webpubsub.sendToGroup.<group>`| The client can publish messages to group `<group>`. |
87
87
|||
88
88
89
+
## AckId and Ack Response
90
+
91
+
The PubSub WebSocket Client supports `ackId` property for `joinGroup`, `leaveGroup`, `sendToGroup` and `event` messages. When using `ackId`, you can receive an ack response message when your request is processed. You can choose to omit `ackId` in fire-and-forget scenarios. In the article, we describe the behavior differences between specifying `ackId` or not.
92
+
93
+
### Behavior when No `ackId` specified
94
+
95
+
If `ackId` is not specified, it's fire-and-forget. Even there're errors when brokering messages, you have no way to get notified.
96
+
97
+
### Behavior when `ackId` specified
98
+
99
+
#### Idempotent publish
100
+
101
+
`ackId` is a uint64 number and should be unique within a client with the same connection id. Web PubSub Service records the `ackId` and messages with the same `ackId` will be treated as the same message. The service refuses to broker the same message more than once, which is useful in retry to avoid duplicated messages. For example, if a client sends a message with `ackId=5` and fails to receive an ack response with `ackId=5`, then the client retries and sends the same message again. In some cases, the message is already brokered and the ack response is lost for some reason, the service will reject the retry and response an ack response with `Duplicate` reason.
102
+
103
+
#### Ack Response
104
+
105
+
Web PubSub Service sends ack response for each request with `ackId`.
*`success` is a bool and indicate whether the request is successfully processed by the service. If it is `false`, clients need to check the `error`.
123
+
124
+
*`error` only exists when `success` is `false` and clients should have different logic for different `name`. You should suppose there might be more type of `name` in future.
125
+
-`Forbidden`: The client doesn't have the permission to the request. The client needs to be added relevant roles.
126
+
-`InternalServerError`: Some internal error happened in the service. Retry is required.
127
+
-`Duplicate`: The message with the same `ackId` has been already processed by the service.
128
+
129
+
89
130
For more information about the JSON subprotocol, see [JSON subprotocol](./reference-json-webpubsub-subprotocol.md).
90
131
91
132
For more information about the protobuf subprotocol, see [Protobuf subprotocol](./reference-protobuf-webpubsub-subprotocol.md).
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/reference-json-webpubsub-subprotocol.md
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,11 +49,11 @@ Format:
49
49
{
50
50
"type": "joinGroup",
51
51
"group": "<group_name>",
52
-
"ackId" : 1// optional
52
+
"ackId" : 1
53
53
}
54
54
```
55
55
56
-
*`ackId` is optional, it's an incremental integer for this command message. When the `ackId` is specified, the service sends a [ack response message](#ack-response)back to the client when the command is executed.
56
+
*`ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
57
57
58
58
### Leave groups
59
59
@@ -63,11 +63,11 @@ Format:
63
63
{
64
64
"type": "leaveGroup",
65
65
"group": "<group_name>",
66
-
"ackId" : 1// optional
66
+
"ackId" : 1
67
67
}
68
68
```
69
69
70
-
*`ackId` is optional, it's an incremental integer for this command message. When the `ackId` is specified, the service sends a [ack response message](#ack-response)back to the client when the command is executed.
70
+
*`ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
71
71
72
72
### Publish messages
73
73
@@ -77,14 +77,14 @@ Format:
77
77
{
78
78
"type": "sendToGroup",
79
79
"group": "<group_name>",
80
-
"ackId" : 1,// optional
80
+
"ackId" : 1,
81
81
"noEcho": true|false,
82
82
"dataType" : "json|text|binary",
83
83
"data": {}, // data can be string or valid json token depending on the dataType
84
84
}
85
85
```
86
86
87
-
*`ackId` is optional, it's an incremental integer for this command message. When the `ackId` is specified, the service sends a [ack response message](#ack-response)back to the client when the command is executed.
87
+
*`ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
88
88
*`noEcho` is optional. If set to true, this message is not echoed back to the same connection. If not set, the default value is false.
89
89
*`dataType` can be one of `json`, `text`, or `binary`:
90
90
*`json`: `data` can be any type that JSON supports and will be published as what it is; If `dataType` isn't specified, it defaults to `json`.
@@ -97,7 +97,8 @@ Format:
97
97
"type": "sendToGroup",
98
98
"group": "<group_name>",
99
99
"dataType" : "text",
100
-
"data": "text data"
100
+
"data": "text data",
101
+
"ackId": 1
101
102
}
102
103
```
103
104
@@ -146,7 +147,8 @@ Format:
146
147
"type": "sendToGroup",
147
148
"group": "<group_name>",
148
149
"dataType" : "binary",
149
-
"data": "<base64_binary>"
150
+
"data": "<base64_binary>",
151
+
"ackId": 1
150
152
}
151
153
```
152
154
@@ -170,11 +172,14 @@ Format:
170
172
{
171
173
"type": "event",
172
174
"event": "<event_name>",
175
+
"ackId": 1,
173
176
"dataType" : "json|text|binary",
174
177
"data": {}, // data can be string or valid json token depending on the dataType
175
178
}
176
179
```
177
180
181
+
*`ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
182
+
178
183
`dataType` can be one of `text`, `binary`, or `json`:
179
184
*`json`: data can be any type json supports and will be published as what it is; If `dataType` is not specified, it defaults to `json`.
180
185
*`text`: data should be in string format, and the string data will be published;
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/reference-protobuf-webpubsub-subprotocol.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,23 +64,24 @@ message UpstreamMessage {
64
64
65
65
message SendToGroupMessage {
66
66
string group = 1;
67
-
optional int32 ack_id = 2;
67
+
optional uint64 ack_id = 2;
68
68
MessageData data = 3;
69
69
}
70
70
71
71
message EventMessage {
72
72
string event = 1;
73
73
MessageData data = 2;
74
+
optional uint64 ack_id = 3;
74
75
}
75
76
76
77
message JoinGroupMessage {
77
78
string group = 1;
78
-
optional int32 ack_id = 2;
79
+
optional uint64 ack_id = 2;
79
80
}
80
81
81
82
message LeaveGroupMessage {
82
83
string group = 1;
83
-
optional int32 ack_id = 2;
84
+
optional uint64 ack_id = 2;
84
85
}
85
86
}
86
87
@@ -99,21 +100,21 @@ Format:
99
100
100
101
Set `join_group_message.group` to the group name.
101
102
102
-
*`ackId` is optional. It's an incremental integer for this command message. If you specify `ackId`, the service sends an[ack response message](#ack-response)back to the client when the command is executed.
103
+
*`ackId` is the identity of each request and should be unique. The service sends a[ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
103
104
104
105
### Leave groups
105
106
106
107
Format:
107
108
108
109
Set `leave_group_message.group` to the group name.
109
110
110
-
*`ackId` is optional. It's an incremental integer for this command message. If you specify `ackId`, the service sends an[ack response message](#ack-response)back to the client when the command is executed.
111
+
*`ackId` is the identity of each request and should be unique. The service sends a[ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
111
112
112
113
### Publish messages
113
114
114
115
Format:
115
116
116
-
*`ackId` is optional. It's an incremental integer for this command message. If you specify `ackId`, the service sends an[ack response message](#ack-response)back to the client when the command is executed.
117
+
*`ackId` is the identity of each request and should be unique. The service sends a[ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](./concept-client-protocols.md#ackid-and-ack-response)
117
118
118
119
There's an implicit `dataType`, which can be `protobuf`, `text`, or `binary`, depending on the `data` in `MessageData` you set. The receiver clients can use `dataType` to handle the content correctly.
0 commit comments