exchange_declare
Declares an AMQP exchange with the specified name, type, and durability settings via the active channel. This function performs a network call to the broker and automatically attempts to reconnect if the channel is unavailable or an error occurs during declaration.
def exchange_declare(
amqp_context: object,
exchange: string,
type: string,
passive: boolean = False,
durable: boolean = False,
auto_delete: boolean = False
) - > null
Declares an exchange on the AMQP broker, creating it if it does not exist or verifying its existence if the passive flag is set.
Parameters
| Name | Type | Description |
|---|---|---|
| amqp_context | object | The context object containing the active AMQP channel and connection state. |
| exchange | string | The unique name of the exchange to be declared. |
| type | string | The exchange type, such as 'direct', 'fanout', 'topic', or 'headers', which determines routing logic. |
| passive | boolean = False | If true, the server will only check if the exchange exists; if it does not, an error is raised. |
| durable | boolean = False | If true, the exchange will survive broker restarts. |
| auto_delete | boolean = False | If true, the exchange is deleted when all queues have finished using it. |
Returns
| Type | Description |
|---|---|
null | Nothing is returned; the function outputs the operation status to the console and handles reconnection on failure. |