BasicConsume Arguments Exception

478 views
Skip to first unread message

Dennis G

unread,
Feb 11, 2022, 11:55:46 AM2/11/22
to rabbitmq-users
I am using the C# dotnet client in a dotnet core app.

All has worked great (exchange/queue/channel construction, etc). 

I can publish to queues with no issues.

However, when I attempt to call BasicConsume with the arg list shown in all the docs and examples (queue, false, consumer), the compiler complains that I am missing required args.

Looking at the prototype for EventingBasicConsumer I see that BasicConsume takes several args:

string BasicConsume(string queue, bool autoAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments, IBasicConsumer consumer);

I attempt to call BasicConsume as follows:

Dictionary<string, object> args = new Dictionary<string, object>();
queueConsumerTag = channel.BasicConsume(queueName, false, "someTag", false, false, args, consumer);

I get an exception: "Value cannot be null. (Parameter 'chars')" I can find no documentation or examples about this and cannot get a basic consume to work.

Anyone have any ideas what is going on?

Luke Bakken

unread,
Feb 11, 2022, 1:36:57 PM2/11/22
to rabbitmq-users
Hi Dennis,

That's pretty strange. Would you mind providing a complete project via a git repository that I can clone and compile to see the same error?

What versions of the following software are you using?
  • RabbitMQ .NET Client
  • .NET Core SDK
Thanks -
Luke

Dennis G

unread,
Feb 12, 2022, 9:29:59 AM2/12/22
to rabbitmq-users
Update,

Not sure what the cause was. When creating the channel (channel = connection.CreateModel()), if I examined the metadata for channel.BasicConsume, it referenced the file IModel. 

IModel only defines 1 BasicConsume:

[AmqpMethodDoNotImplementAttribute(null)]
        string BasicConsume(string queue, bool autoAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments, IBasicConsumer consumer);

In the usual examples, CreateModel returns a channel object that when you examine its BasicConsume definition, the metadata file that appears is IModelExtensions (which has 4 overloads of BasicConsume):
       //
        // Summary:
        //     Start a Basic content-class consumer.
        public static string BasicConsume(this IModel model, IBasicConsumer consumer, string queue, bool autoAck = false, string consumerTag = "", bool noLocal = false, bool exclusive = false, IDictionary<string, object> arguments = null);
        //
        // Summary:
        //     Start a Basic content-class consumer.
        public static string BasicConsume(this IModel model, string queue, bool autoAck, IBasicConsumer consumer);
        //
        // Summary:
        //     Start a Basic content-class consumer.
        public static string BasicConsume(this IModel model, string queue, bool autoAck, string consumerTag, IBasicConsumer consumer);
        //
        // Summary:
        //     Start a Basic content-class consumer.
        public static string BasicConsume(this IModel model, string queue, bool autoAck, string consumerTag, IDictionary<string, object> arguments, IBasicConsumer consumer);
 

For some reason the extension was not being applied(?) to the channel instance returned by CreateModel()

I ended up uninstalling the client package, then reinstalling and the issue went away.

Mystery of the day.

Reply all
Reply to author
Forward
0 new messages