This topic describes the cause and troubleshooting method of an ExchangeHasDiffFields error that is reported on an ApsaraMQ for RabbitMQ client.
Problem description
When you attempt to access an ApsaraMQ for RabbitMQ broker from an ApsaraMQ for RabbitMQ 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 | Type | Description |
exchange | String | The exchange name. |
type | String | The exchange type. 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 in the ApsaraMQ for RabbitMQ 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 in the ApsaraMQ for RabbitMQ 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 the durable parameter of the exchange to use is inconsistent with that of the declared exchange, ExchangeHasDiffFields[ODurable=true&NDurable=false;] is reported.
The value of the durable parameter of the exchange to use is false.
NoteYou can call the ListExchanges API operation or perform operations on the Exchanges page in the ApsaraMQ for RabbitMQ console to obtain the values of the attribute parameters for the exchange to use.
The value of the durable parameter of 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 the value is consistent with that of the exchange to use. In the following example, the value of the durable parameter is changed to false.
Sample code:
channel.exchangeDeclare("test", "direct", true, false, false, null);