Closed
Description
Describe the bug
Endless sending of messages to a non-existent exchange when PublisherConfirmationsEnabled = false or PublisherConfirmationsEnabled = true and PublisherConfirmationTrackingEnabled = false.
Attached is a sample code that causes the error. Is this normal behavior or not?
And why?
At
PublisherConfirmationsEnabled = true
PublisherConfirmationTrackingEnabled = true
It works correctly
RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=504, text='CHANNEL_ERROR - expected 'channel.open'', classId=60, methodId=40
Reproduction steps
- Run Code
- See log
Expected behavior
Works stably
Additional context
static async Task Main(String[] args)
{
var factory = new ConnectionFactory
{
HostName = "localhost",
Port = 5672,
UserName = "guest",
Password = "guest"
};
var connection = await factory.CreateConnectionAsync();
connection.ConnectionShutdownAsync += Connection_ConnectionShutdownAsync;
var options = new CreateChannelOptions(false, false);
var json = "{ \"A\" : \"X\"}";
var body = Encoding.UTF8.GetBytes(json);
var bp = new BasicProperties
{
ContentType = MediaTypeNames.Application.Json,
ContentEncoding = "UTF-8",
};
IChannel channel = await connection.CreateChannelAsync(options);
channel.ChannelShutdownAsync += Channel_ChannelShutdownAsync;
while (true)
{
try
{
await channel.BasicPublishAsync("NotExistsExchange", String.Empty, true, bp, body);
Console.WriteLine("send");
}
catch (AlreadyClosedException)
{
Console.WriteLine("not send");
}
if (channel.IsClosed)
{
channel = await connection.CreateChannelAsync(options); // The error occurs here
Console.WriteLine("Recreate");
channel.ChannelShutdownAsync += Channel_ChannelShutdownAsync;
}
}
}
private static async Task Connection_ConnectionShutdownAsync(object sender, RabbitMQ.Client.Events.ShutdownEventArgs @event)
{
Console.WriteLine("Connection: " + @event.ReplyCode);
}
private static async Task Channel_ChannelShutdownAsync(object sender, RabbitMQ.Client.Events.ShutdownEventArgs @event)
{
Console.WriteLine("Channel: " + @event.ReplyCode);
}
}
Metadata
Metadata
Assignees
Labels
No labels