Conectando RabbitMQ usando C#
Frecuentes
Visto 11,276 veces
2
I am using the sample code available at internet but I am getting an exception and I am not able to solve this error.
Estoy recibiendo esta excepción
BrokerUnreachableExceptionCaught None of the specified endpoints were reachable
No idea how to resolve this error. There are so many links that have posted the encounter of error but none of them have it's resolution. Please help me regarding this. Your suggestions will be helpful to me.. Please help as soon as possible.
Algunos enlaces
- http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2012-September/022407.html
- http://comments.gmane.org/gmane.comp.networking.rabbitmq.general/18329
Código:
try
{
ConnectionFactory factory = new ConnectionFactory();
factory.UserName = "user";
factory.Password = "password";
factory.VirtualHost = "/";
factory.Protocol = Protocols.FromEnvironment();
factory.HostName = "localhost";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
IConnection conn = factory.CreateConnection();
//using (var connection = factory.CreateConnection())
//{
// using (var channel = connection.CreateModel())
// {
// channel.QueueDeclare("hello", false, false, false, null);
// string message = "Hello World!";
// var body = Encoding.UTF8.GetBytes(message);
// channel.BasicPublish("", "hello", null, body);
// Console.WriteLine(" [x] Sent {0}", message);
// }
//}
}
catch
{
}
2 Respuestas
3
The BrokerUnreachableException thrown has the following useful properties:
ConnectionAttempts ConnectionErrors
Take a look at these to see if there's any extra information (for example, perhaps the password is incorrect.)
Respondido el 22 de Septiembre de 13 a las 23:09
yes , I was giving user name and password from my end, I removed username and password lines , and it starts Working. Can you please suggest how can I check id queue is getting something or not. Can we check if something got saved in the queue or not? - Sandy
Actually var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); is not returning anything. It is not returning anything. Please help me ASAP. - Sandy
@Sandy, please post another question regarding the Dequeue problem with some example code, and link to it in a comment, I'll take a look. - daniel james bryars
Just thought, you might find it really useful to add the web management plugin to your Rabbit broker, and log into that (rabbitmq.com/management.html). You can then see the queues, and look at the messages in that management UI. - daniel james bryars
Sir, please have a look at this question and please help me.stackoverflow.com/questions/18959927/… - Sandy
0
RabbitMQ localhost connection in Asp.net core, in Nugget Package, browse RabbitMQ.Client
//localhost connection, these both worked for me.
var factory = new ConnectionFactory() { HostName = "localhost" };
or
var factory = new ConnectionFactory();
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "HelloNewWorld",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
string message = "Hello World!";
var body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(exchange: "",
routingKey: "HelloNewWorld",
basicProperties: null,
body: body);
Console.WriteLine(" [x] Sent {0}", message);
}
}
//default localhost for rabbitmq
http://localhost:15672/queues
Asp.NetCore #RabbitMQ
Respondido el 20 de junio de 20 a las 10:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# asp.net-mvc rabbitmq or haz tu propia pregunta.
Plz look at this post >> stackoverflow.com/a/70507418/5967360 - Mucahid Uslu