-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRabbitServer.cs
36 lines (32 loc) · 980 Bytes
/
RabbitServer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Configuration;
using RabbitMQ.Client;
namespace Tatweer.Traffic
{
public static class RabbitServer
{
public static ConnectionFactory CreateFactory()
{
var settings = ConfigurationManager.AppSettings;
var hostName = settings["amqpUri"];
var port = int.Parse(settings["port"]);
var user = settings["user"];
var pass = settings["pass"];
return new ConnectionFactory
{
HostName = hostName,
Port = port,
UserName = user,
Password = pass
};
}
public static IConnection GetConnection()
{
var factory = CreateFactory();
return factory.CreateConnection();
}
public static IModel GetChannel(IConnection connection)
{
return connection.CreateModel();
}
}
}