Rabbitmq的使用及Web监控工具使用
本文转载自:https://www.cnblogs.com/gossip/p/4475978.html
windows安装手册请参考:http://www.rabbitmq.com/install-windows-manual.html
一、文档资料
32位:OTP 17.5 Windows 32-bit Binary File (91.0 MB)
3、下载并安装.Net客户端:http://www.rabbitmq.com/dotnet.html
http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.5.1/rabbitmq-dotnet-client-3.5.1-dotnet-4.0.zip

namespace Server
{
class Program
{
static void Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
//定义队列(hello为队列名)
channel.QueueDeclare("hello", false, false, false, null); var consumer = new QueueingBasicConsumer(channel);
channel.BasicConsume("hello", true, consumer); Console.WriteLine(" [*] Waiting for messages." +
"To exit press CTRL+C");
while (true)
{
//接受客户端发送的消息并打印出来
var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
Console.WriteLine(" [x] Received {0}", message);
}
}
}
}
}
}

namespace Client
{
class Program
{
static void Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
//定义队列(hello为队列名)
channel.QueueDeclare("hello", false, false, false, null);
//发送到队列的消息,包含时间戳
string message = "Hello World!" + "_" + DateTime.Now.ToString();
var body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish("", "hello", null, body);
Console.WriteLine(" [x] Sent {0}", message);
}
}
}
}
}



六、异常问题
1、None of the specified endpoints were reachable
生产端和消费端的factory参数要统一
var factory = new ConnectionFactory();
factory.UserName = QueueSetttiong.UserName; //用户名,对应Management工具的admin-->user
factory.Password = QueueSetttiong.Password; //密码,对应Management工具的admin-->密码
factory.HostName = QueueSetttiong.HostName; //本地部署服务直接用hostname即可
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.VirtualHost = QueueSetttiong.VirtualHost; //使用默认值: "/"
factory.Protocol = Protocols.DefaultProtocol;
Rabbitmq的使用及Web监控工具使用的更多相关文章
- [转]Rabbitmq的使用及Web监控工具使用
本文转自:https://blog.csdn.net/xingxing513234072/article/details/51014850 一.文档资料 1.官方网站:http://ww ...
- 消息队列系列(二):.Rabbitmq的使用及Web监控工具使用
一.文档资料 1.官方网站:http://www.rabbitmq.com/ 2.安装教程:http://www.rabbitmq.com/install-windows. ...
- Web监控工具
.Rabbitmq的使用及Web监控工具使用 一.文档资料 1.官方网站:http://www.rabbitmq.com/ 2.安装教程:http://www.rabb ...
- Erlang Web 监控工具
转自http://www.cnblogs.com/me-sa/archive/2012/04/17/erlang-web-monitor.html Erlang已经提供了一系列工具查看运行时状态查看 ...
- rabbitmq启用和禁用web界面管理插件
rabbitmq默认安装启动以后,是没有开启web管理界面的,通过rabbitmq-plugins list命令可列出插件的启用和禁用状态. 使用rabbitmq-plugins enable xxx ...
- rabbitMQ教程(五)rabbitmq 指令 以及解决web管理界面无法使用guest用户登录
安装最新版本的rabbitmq(3.3.1),并启用management plugin后,使用默认的账号guest登陆管理控制台,却提示登陆失败. 翻看官方的release文档后,得知由于账号gues ...
- Django开发Web监控工具-pyDash
今天发现了一个比较有意思的监控工具,是基于Django开发的,开发大牛已经开放了源代码,向大牛致敬,同时研究研究,目前感觉这个监控比较直观,可以针对个人服务器使用,同时涉及的环境比较简单,部署起来 ...
- Mycat Web监控工具
简介 Mycat-web 是 Mycat 可视化运维的管理和监控平台,弥补了 Mycat 在监控上的空白.帮 Mycat 分担统计任务和配置管理任务.Mycat-web 引入了 ZooKeeper 作 ...
- 消息队列系列(三):.Rabbitmq Trace的使用
一.什么是Trace Trace是Rabbitmq用于记录每一次发送的消息,方便使用Rabbitmq的开发者调试.排错.可通过插件形式 提供可视化界面 二.Trace实现概况 ...
随机推荐
- layui---十分适用于PC端后台的框架
1.关闭当前页面: top.$(".layui-tab-title").find("li.layui-this>i").click(); 2.调用指定ID ...
- Python中安装bs4后,pycharm依然报错ModuleNotFoundError: No module named 'bs4'
学习网络抓取时,第一步出现问题. 执行示例代码 from urllib.request import urlopen from bs4 import BeautifulSoup html = urlo ...
- springboot使用Redis,监听Redis键过期的事件设置与使用代码
我使用的是Windows下的Redis服务,所以一下Redis设置都是在Windows平台进行. 1.修改Redis配置文件 1.1:Windows下的Redis存在两个配置文件 修改带有servic ...
- nuget安装本地nupkg文件
打开visual studio,菜单选择‘工具’->‘选项’ 然后 接下来,选择‘程序包源’,把‘包括预发行版’打钩,然后安装需要的包到工程即可,如下图:
- jquery.validate 远程验证remote使用详解
目的: 试了一下远程验证,试了好几次,得出小结,可以记录下,提醒以防绕路. ----------------直接贴图,省事明了---------------- 1.引用js 2.demo的html & ...
- Similarity measure
1. https://blog.csdn.net/m0_37676632/article/details/68936157 2. https://www.cnblogs.com/pinard/p/62 ...
- GUI学习之八——QToolButton的学习总结
QToolButton提供一个快速的访问按钮,通常在工具栏内使用,一般不显示文本标签而显示图标. 一.按钮的样式风格设置 可以按照下面的风格对按钮进行样式设置 从左到右依次是仅显示图标.仅显示文字.图 ...
- MySQL 1053错误 服务无法正常启动的解决方法
MySQL 1053错误 服务无法正常启动的解决方法 1.右键我的电脑,管理,进入服务 2.右键单击Mysql8 属性,选择登陆 选择此账号 登陆管理员账号
- 使用rancher2建k8s集群--个人学习记录
视频地址这里: http://live.vhall.com/431874021 原生文档这里:https://www.cnrancher.com/docs/rancher/v2.x/cn/overvi ...
- oracle存储过程 out cursor
create or replace procedure BUILDEMPLID(emp_cursor out sys_refcursor) is n_emplid number; n_emplid1 ...
