Created
March 11, 2013 03:39
-
-
Save zhuqling/5131735 to your computer and use it in GitHub Desktop.
创建RabbitMQ连接和通道(包含publisher confirm), 关闭通道和连接
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly ConnectionFactory _connFactory = new ConnectionFactory(); | |
private IConnection _conn; | |
private IModel _chan; | |
private const string Host = "192.168.1.200"; | |
private const string UserName = "guest"; | |
private const string Password = "guest"; | |
private void InitRabbit() | |
{ | |
_connFactory.HostName = Host; | |
_connFactory.UserName = UserName; | |
_connFactory.Password = Password; | |
_conn = _connFactory.CreateConnection(); | |
_chan = _conn.CreateModel(); | |
_chan.ConfirmSelect(); | |
} | |
private void CloseRabbit() | |
{ | |
_chan.Close(); | |
_conn.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment