All Products
Search
Document Center

ApsaraMQ for RabbitMQ:How do I troubleshoot an ExchangeHasDiffFields error reported on an ApsaraMQ for RabbitMQ client?

Last Updated:Aug 21, 2024

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.

Note

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:

  • fanout: An exchange of this type routes all the received messages to all the queues bound to this exchange. You can use a fanout exchange to broadcast messages.

  • direct: An exchange of this type routes a message to the queue whose routing key is exactly the same as the routing key of the message.

  • topic: This type is similar to the direct exchange type. An exchange of this type routes a message to one or more queues based on the fuzzy match or multi-condition match result between the routing key of the message and the routing key of the current exchange.

durable

boolean

Specifies whether the exchange is durable. Valid values:

  • true: The exchange is automatically restored when the ApsaraMQ for RabbitMQ client is reconnected to the ApsaraMQ for RabbitMQ broker.

  • false: The exchange is not automatically restored when the ApsaraMQ for RabbitMQ client is reconnected to the ApsaraMQ for RabbitMQ broker.

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:

  • true: The exchange is automatically deleted after the last bound queue is unbound from the exchange.

  • false: The exchange is not automatically deleted after the last bound queue is unbound from the exchange.

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:

  • true: The exchange is bound to another exchange.

  • false: The exchange is bound to a queue.

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.

    Note

    You 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);