使用.net客户端发布到RabbitMQ时出现invalid_frame_end_marker错误

时间:2015-07-15 17:34:37

标签: rabbitmq

我正在使用RabbitMQ .net客户端库以下列方式将消息发布到RabbitMQ节点。

var factory = new ConnectionFactory
                {
                    HostName = "localhost",
                    Port = 5672,
                    UserName = "guest",
                    Password = "guest",
                    VirtualHost = @"/"
                };
_conn = factory.CreateConnection();

_channel = _conn.CreateModel();

_properties = _channel.CreateBasicProperties();

然后在循环中调用以下内容

using (var memStream = new MemoryStream())
{
    var formatter = new BinaryFormatter();

    formatter.Serialize(memStream, message);

    var properties = _channel.CreateBasicProperties();
    properties.Priority = Convert.ToByte((int) priority);

   _channel.BasicPublish(String.Empty, _routeKey, properties, memStream.ToArray());
 }

上面的代码工作正常,中等负载大约每秒50-100条消息。但是当我增加每秒发送大约500条消息的消息数时,RabbitMQ节点开始提供以下错误并断开频道。

Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=501, text="FRAME_ERROR - type 206, first 16 octets = <<31,0,60,0,40,0,0,6,115,101,110,115,111,114,16,115>>:
{invalid_frame_end_marker, 114}
", classId=0, methodId=0, cause=: 
at RabbitMQ.Client.Impl.SessionBase.Transmit(Command cmd) 
at RabbitMQ.Client.Impl.ModelBase.ModelSend(MethodBase method, ContentHeaderBase header, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, Boolean mandatory, Boolean immediate, IBasicProperties basicProperties, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, Boolean mandatory, IBasicProperties basicProperties, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, IBasicProperties basicProperties, Byte[] body)`

BinaryFormatter的消息大小约为5kb。

0 个答案:

没有答案
相关问题