Junior — Middle
Kas saaksite selgitada, mida tähendab durable atribuut RabbitMQ vahetuse seadetes?
sobes.tech AI
Vastus AI-lt
The durable attribute in the RabbitMQ exchange configuration determines whether the exchange will be saved to disk and restored after a RabbitMQ server restart. If durable is set to true, the exchange is considered durable and will not disappear upon broker restart. If false, the exchange will be temporary and will be deleted upon restart.
Example of creating a durable exchange in C# using the RabbitMQ.Client library:
var factory = new ConnectionFactory() { HostName = "localhost" };
using var connection = factory.CreateConnection();
using var channel = connection.CreateModel();
channel.ExchangeDeclare(exchange: "my_exchange", type: ExchangeType.Direct, durable: true);
Thus, a durable exchange guarantees the preservation of the exchange configuration between restarts of RabbitMQ, which is important for the stable operation of the messaging system.