C#.Net consumer class error - RabbitMQ 3.6.0 versus 3.11.17

96 views
Skip to first unread message

Lulu Paul

unread,
Aug 14, 2023, 3:25:42 PM8/14/23
to rabbitmq-users
Hello team,

Here are 2 consumer classes but one is from the 3.6.0 version and the other is the modified version with 3.11.17. 

The older version was synchronous and it worked well. The newer version  is asynchronous and is throwing an out of memory exception on the consumer.Received event (the text marked red) . Could you please help understand why it would run out of memory here?

Consumer class  - RabbitMQ 3.6.0  

public void Start(string rabbitQueue)
{
Subscript = new Subscription(Model, rabbitQueue, false);
var consumer = new ConsumeDelegate(Poll);
consumer.Invoke();
}

private void Poll()
{
if (Process == null)
{
if (Logger != null) { Logger.Error("Process is null in Consumer<TMessage>.Poll()"); }
throw new InvalidOperationException("Process is null in Consumer<TMessage>.Poll()");
}

if (Routing.IsEnabled)
{
BasicDeliverEventArgs delivery;
do
{
if (Subscript.Next(500, out delivery) && delivery != null)
{
var jsonString = Encoding.Default.GetString(delivery.Body);
var message = JsonConvert.DeserializeObject<TMessage>(jsonString);

Process(message);

Subscript.Ack(delivery);
}
} while(delivery != null);
}
}

Consumer class  - RabbitMQ  3.11.17

public void Start(string rabbitQueue)
{

var consumer = new EventingBasicConsumer(Model);
Model.BasicConsume(rabbitQueue, false, consumer);

while (Routing.IsEnabled)
{
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
string jsonString = Encoding.Default.GetString(body);
var message = JsonConvert.DeserializeObject<TMessage>(jsonString);

Process(message);
Model.BasicAck(ea.DeliveryTag, false);
};

}

}

Luke Bakken

unread,
Aug 14, 2023, 7:42:27 PM8/14/23
to rabbitmq-users
Hello,

I'm assuming that you're talking about version 5 of the .NET client library, versus version 6.5.0 (the current version).

What is the version of the .NET client that you are using in the latter scenario?

Can you provide code I can compile and run to reproduce this behavior?

How large is the message you're trying to deserialize?

Thanks,
Luke

On Monday, August 14, 2023 at 12:25:42 PM UTC-7 lulusa...@gmail.com wrote:

The older version was synchronous and it worked well. The newer version  is asynchronous and is throwing an out of memory exception on the consumer.Received event (the text marked red) . Could you please help understand why it would run out of memory here?

Lulu Paul

unread,
Aug 24, 2023, 7:46:32 AM8/24/23
to rabbitm...@googlegroups.com
Hi Luke,

Thank you for your reply. 

For the latter one, we have a Windows 2019 server set up with RabbitMQ 3.11.17 with Erlang OTP 25.3.2. The client side dot net code is running on .Net framework 4.8 and the RabbitMQ .Net Client 6.5.0. 


The message size is only 1MB

The out of memory exception occurs in the Consumer.cs class in the Start method - 

while (Routing.IsEnabled)
{
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
string jsonString = Encoding.Default.GetString(body);
var message = JsonConvert.DeserializeObject<TMessage>(jsonString);

Process(message);
Model.BasicAck(ea.DeliveryTag, false);
};
}

Thank you!


--
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/3d04919d-c8c3-4d1b-adc7-e6746e5b63f7n%40googlegroups.com.

Lulu Paul

unread,
Aug 29, 2023, 5:05:56 AM8/29/23
to rabbitm...@googlegroups.com
Dear Luke,

Thank you for your patience with this. Please could you have a look at the project when you get a chance - many thanks!

Best wishes,
LP

Luke Bakken

unread,
Aug 29, 2023, 8:56:42 AM8/29/23
to rabbitmq-users
Please do not reply to a thread to bump it. The people who provide free support on this mailing list do so when they have time.
Reply all
Reply to author
Forward
0 new messages