首页 技术 正文
技术 2022年11月18日
0 收藏 353 点赞 2,344 浏览 2090 个字

一、链接到RabbitMQ

1,创建连接

注意不能有空格

var bus = RabbitHutch.CreateBus(“host=myServer;virtualHost=myVirtualHost;username=mike;password=topsecret”);

1)host(必填):

例如:host=localhost或者host=192.168.2.56或者host=myhost.mydomain.com

使用标准格式主机:端口(host=myhost.com:5673)

如果省略端口号,默认端口使用AMQP(5672)

连接到RabbitMQ集群,每个集群节点指定以逗号分隔(host=myhost1.com,myhost2.com,myhost3.com)

2)virtualHost(默认‘/’):

例如:virtualHost=myVirtualHost

3)username(默认guest):

例如:username=mike

4) password(默认guest):

例如:password=mysecret

5)requestedheartbeat(默认值是10秒):

例如:requestedHeartbeat=10。设置为0,没有心跳。

6) prefetchcount(默认值是50):

例如:prefetchcount=1。这是由EasyNetQ发送ack之前由RabbitMQ发送的消息数。 设置为0用于无限预取(不推荐)。 设置为1,在消费者农场之间进行公平的工作平衡。

 7)publisherConfirms(默认为false):

例如:publisherConfirms=true,这打开了Publisher Confirms.。

8) persistentMessages(默认为true): 

例如:persistentMessages=false。这决定了在发布消息时如何设置basic.properties中的delivery_mode。 false = 1,true = 2。 当设置为true时,消息将由RabbitMQ持久存储到磁盘,并在服务器重新启动后生存。 当设置为false时,可以预期性能提升。

9) product(默认值是实例化总线的可执行文件的名称):

例如:product=My really important service。在EasyNetQ 0.27.3中引入。 此处输入的值将显示在RabbitMQ的管理界面中。

10) platform( 默认值是运行客户端进程实例化总线的机器的主机名):

例如platform = my.fully.qualified.domain.name。在EasyNetQ 0.27.3中引入。 此处输入的值将显示在RabbitMQ的管理界面中。

11)timeout(默认为10秒):

例如timeout = 60。 在EasyNetQ 0.17中推出。 解析为System.UInt16。 范围从0到65535.格式为秒。 对于无限超时,请使用0。超出值时抛出System.TimeoutException。

2,关闭连接

bus.Dispose();

这将关闭EasyNetQ使用的连接,渠道,消费者和所有其他资源。

二、连接SSL

var connection = new ConnectionConfiguration();connection.Port = ;
connection.UserName = "user";
connection.Password = "pass";
connection.Product = "SSLTest";var host1 = new HostConfiguration();
host1.Host = "rmq1.contoso.com";
host1.Port = ;
host1.Ssl.Enabled = true;
host1.Ssl.ServerName = "rmq1.contoso.com";
host1.Ssl.CertPath = "c:\\tmp\\myclient.p12";
host1.Ssl.CertPassphrase = "secret";var host2 = new HostConfiguration();
host2.Host = "rmq2.contoso.com";
host2.Port = ;
host2.Ssl.Enabled = true;
host2.Ssl.ServerName = "rmq2.contoso.com";
host2.Ssl.CertPath = "c:\\tmp\\myclient.p12";
host2.Ssl.CertPassphrase = "secret";connection.Hosts = new List<HostConfiguration> { host1, host2 };connection.Validate(); //非常重要var Bus = RabbitHutch.CreateBus(connection, services => services.Register<IEasyNetQLogger>(logger => new DoNothingLogger()));
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918