createEventQueueBinding method
Creates a new queue binding to the eventExchange
in the
S3I-Broker.
Use topic
to specify on which AMQP message topic the queue should be
bound. Use the optional parameter queueLength
(> 0) if you need a
specific queue length.
Throws a NetworkAuthenticationException if
AuthenticationManager.getAccessToken fails. Throws a SocketException
if no internet connection is available. Throws a
NetworkResponseException if the received status code is not 201. Throws
a ResponseParsingException if something went wrong during the parsing
to an Endpoint.
Implementation
Future<Endpoint> createEventQueueBinding(String thingId, String topic,
{int queueLength = 0}) async {
final Map<String, dynamic> requestBody = <String, dynamic>{'topic': topic};
if (queueLength > 0) {
requestBody['queue_length'] = queueLength;
}
final Response response = await postConfig('/things/$thingId/broker/event',
jsonBody: requestBody);
if (response.statusCode != 201) throw NetworkResponseException(response);
try {
return Endpoint((jsonDecode(response.body)
as Map<String, dynamic>)['queue_name'] as String);
} on TypeError catch (e) {
throw ResponseParsingException(
InvalidJsonSchemaException(e.stackTrace.toString(), response.body));
}
}