All Products
Search
Document Center

ApsaraMQ for RabbitMQ:How do I deal with an ExchangeHasDiffFields error that is reported on the ApsaraMQ for RabbitMQ client?

Last Updated:May 26, 2023

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.

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

Data type

Description

exchange

String

The name of the exchange.

type

String

The type of the exchange. 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 binding 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 binding keys of the current exchange.

durable

Boolean

Specifies whether the exchange is durable. Valid values:

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

  • false: The exchange is not automatically restored when the ApsaraMQ forRabbitMQ client is reconnected to the ApsaraMQ forRabbitMQ 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 of the ApsaraMQ forRabbitMQ 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 of the ApsaraMQ forRabbitMQ 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 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.

    Note

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