28 lines
645 B
C#
28 lines
645 B
C#
using RabbitMQ.Client;
|
|
|
|
public static class RabbitMqConnectionFactory
|
|
{
|
|
public static ConnectionFactory Create(RabbitMqOptions o, bool dispatchConsumersAsync = false)
|
|
{
|
|
var factory = new ConnectionFactory
|
|
{
|
|
HostName = o.Host,
|
|
Port = o.Port,
|
|
UserName = o.Username,
|
|
Password = o.Password,
|
|
DispatchConsumersAsync = dispatchConsumersAsync,
|
|
};
|
|
|
|
if (o.UseSsl)
|
|
{
|
|
factory.Ssl = new SslOption
|
|
{
|
|
Enabled = true,
|
|
ServerName = o.Host,
|
|
};
|
|
}
|
|
|
|
return factory;
|
|
}
|
|
}
|