This topic describes the cause and troubleshooting method of an ExchangeHasDiffFields error that is reported on a ApsaraMQ forRabbitMQ client.
Symptoms
When I attempt to access a ApsaraMQ forRabbitMQ broker from a ApsaraMQ forRabbitMQ client, an ExchangeHasDiffFields error, such as ExchangeHasDiffFields[ODurable=true&NDurable=false;], is reported.
In the error information, the parameter that starts with O indicates an attribute value of the exchange to use, and the parameter that starts with N indicates an attribute value of the declared exchange.
Causes
An attribute value of the exchange to use is inconsistent with that of the declared exchange. The following table describes the attribute parameters that may be inconsistent.
Parameter | Data type | Description |
exchange | String | The name of the exchange. |
type | String | The type of the exchange. Valid values:
|
durable | Boolean | Specifies whether the exchange is durable. Valid values:
Note By default, an exchange is durable regardless of whether it is created by calling the CreateExchange API operation or on the Exchanges page of the ApsaraMQ forRabbitMQ console. |
autoDelete | Boolean | Specifies whether the exchange can be automatically deleted. Valid values:
Note By default, an exchange is not automatically deleted regardless of whether it is created by calling the CreateExchange API operation or on the Exchanges page of the ApsaraMQ forRabbitMQ console. |
internal | Boolean | Specifies whether the exchange is an internal exchange. Default value: false. Valid values:
|
arguments | Map | Other parameters of the exchange, such as the alternate exchange. |
For example, if the value of durable for the exchange to use is inconsistent with that of the declared exchange, ExchangeHasDiffFields[ODurable=true&NDurable=false;] is reported.
The value of durable for the exchange to use is false.
NoteYou can call the ListExchanges API operation or perform operations on the Exchanges page of the ApsaraMQ forRabbitMQ console to obtain the values of the attribute parameters for the exchange to use.
The value of durable for the declared exchange is true.
Sample code:
channel.exchangeDeclare("test", "direct", false, false, false, null);
Solutions
Change the inconsistent value in the declaration code to ensure that it is consistent with that of the exchange to use. In this example, change the value of durable to false.
Sample code:
channel.exchangeDeclare("test", "direct", true, false, false, null);