IPWorks IoT 2020 JavaScript Edition

Questions / Feedback?

DeleteExchange Method

Deletes an exchange.


async amqpclassic.deleteExchange(channelName : string, exchangeName : string, ifUnused : boolean, noWait : boolean): Promise<void>


This method is used to delete an exchange.

ChannelName controls what channel the class will send the request over. While any channel can technically be used, keep in mind that the server will close it if a channel error occurs. For this reason, it is good practice to make requests such as this one using a channel that is not involved in message publishing or consumption.

ExchangeName must be a non-empty string consisting only of letters, digits, hyphens, underscores, periods, and colons. It must be no longer than 255 characters, and must not begin with amq..

When IfUnused is True, the server will only delete the exchange if no queues are bound to it.

The NoWait parameter, if True, will cause the server to execute the request asynchronously. For asynchronous request handling, the server only sends back a response in case of an error.

An exception is thrown if no channel with the given ChannelName exists, or if the server returns an error because:

  • The value passed for ExchangeName fails one or more of the constraints described above.
  • No exchange named ExchangeName exists. (This does not apply for RabbitMQ; attempting to delete a non-existent exchange will always succeed.)
  • The IfUnused parameter was True, but the exchange still had one or more queues bound to it.

Note that in AMQP, server errors are grouped into "connection errors" and "channel errors", and both are fatal. That is, if the server returns a channel error, it will then close the channel which caused the error; and if it returns a connection error, it will then close the connection. The AMQPClassic class's Error Codes page includes AMQP's various connection and channel errors.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 JavaScript Edition - Version 20.0 [Build 8265]