error CS0115: 'MessageReceiver.HandleBasicDeliver(string, ulong, bool, string, string, IBasicProperties, byte[])': no suitable method found to override

576 views
Skip to first unread message

Seyder

unread,
Apr 27, 2020, 10:32:25 AM4/27/20
to rabbitmq-users
Hi Guys,

I am trying to consume a message from a RabbitMQ queue using c# and when I get the above error in the HandleBasicDeliver method.

Can anyone help, below is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RabbitMQ.Client;


namespace RabbitMQConsumer
{
    class MessageReceiver : DefaultBasicConsumer
    {
        private readonly IModel _channel;

        public MessageReceiver(IModel channel)

        {

            _channel = channel;

        }

        public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)

        {

            Console.WriteLine($"Consuming Message");
            Console.WriteLine(string.Concat("Message received from the exchange ", exchange));
            Console.WriteLine(string.Concat("Consumer tag: ", consumerTag));
            Console.WriteLine(string.Concat("Delivery tag: ", deliveryTag));
            Console.WriteLine(string.Concat("Routing tag: ", routingKey));
            Console.WriteLine(string.Concat("Message: ", Encoding.UTF8.GetString(body)));
            _channel.BasicAck(deliveryTag, false);

        }
    }
}



Regards,

Luke Bakken

unread,
Apr 27, 2020, 10:49:58 AM4/27/20
to rabbitmq-users
Hello,


The compilation error you got explains the issue - the final parameter is not of type byte[] but should be ReadOnlyMemory<byte>

Where did you get this example code?

Thanks -
Luke

Wesley Peng

unread,
Apr 27, 2020, 8:28:55 PM4/27/20
to rabbitm...@googlegroups.com
what're the server and client software versions?

regards.


27 April 2020, 22:32:32, by "Seyder" <sanele....@gmail.com>:

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/19bd19c4-3db6-4316-a953-946462be84b7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages