Here is the node.js code and I'm trying convert it to C# with RabbitMQ Client
amqp.connect('amqp://xxx-url').then(function(conn) {
process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(ch) {
ch.consume('_816_', doWork, {noAck: true});
console.log(" [*] Waiting for messages. To exit press CTRL+C");
});
there is some function Dowork(msg) in the js file
Here is my C# code
using (IConnection connection = Connection)
{
using (IModel channel = connection.CreateModel())
{
var count = channel.MessageCount(queue);
var consumer = new EventingBasicConsumer(channel);
string x = channel.BasicConsume(queue, false, consumer);
//channel.QueueDeclare(queue, false, false, false, null);
BasicGetResult result = channel.BasicGet(queue, true);
if (result != null)
{
string data = Encoding.UTF8.GetString(result.Body.ToArray());
Console.WriteLine(data);
}
}
}
If I try to declare queue I get access denied error, so commented.
I'm always getting null in basic result while it works in js and I continue to get messages.
Basic consume only gives me string, I don't know what is the use of that?
Not sure what I'm doing wrong. Any ideas?