rabbitMQ学习
Posted 光阴易逝,岂容我待
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rabbitMQ学习相关的知识,希望对你有一定的参考价值。
学习地址:
1、http://www.cnblogs.com/ericli-ericli/p/5902270.html
感谢大神的分析,感谢同事的指导。
2、按照要求一步步配置。
3、打开http://localhost:15672/#/
4、创建虚拟账户
单击:赋权限
5、代码如下:下载地址:链接:http://pan.baidu.com/s/1bpKwtND 密码:el5q
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using Sangmado.Inka.MomBrokers; using Sangmado.Inka.MomBrokers.TestConsole; namespace QMessage { class Program { static void Main(string[] args) { Person per = new Person(); per.Id = "123"; per.Name = "hh爱学习"; var publishingChannel = new OutgoingMomChannel( TestPublishingChannelConfiguration.GetHostSetting(), TestPublishingChannelConfiguration.GetExchangeSetting(), TestPublishingChannelConfiguration.GetQueueSetting(), TimeSpan.FromSeconds(15)); var consumingChannel = new IncomingMomChannel( TestConsumingChannelConfiguration.GetHostSetting(), TestConsumingChannelConfiguration.GetExchangeSetting(), TestConsumingChannelConfiguration.GetQueueSetting(), TimeSpan.FromSeconds(15)); publishingChannel.Connect(); consumingChannel.Connect(); publishingChannel.Publish(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(per))); //consumingChannel.StartConsume(); Console.ReadLine(); } } public class Person { public string Id { get; set; } public string Name { get; set; } } }
5、配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<appSettings>
<add key="TestPublishingChannelHostClientServiceName" value="TestConsole"/>
<add key="TestPublishingChannelHostName" value="localhost"/>
<add key="TestPublishingChannelHostPort" value="5672"/>
<add key="TestPublishingChannelHostVirtualHost" value="/prod"/>
<add key="TestPublishingChannelHostUserName" value="guest"/>
<add key="TestPublishingChannelHostPassword" value="guest"/>
<add key="TestPublishingChannelExchangeName" value="test.exchange"/>
<add key="TestPublishingChannelExchangeType" value="fanout"/>
<add key="TestPublishingChannelExchangeDurable" value="false"/>
<add key="TestPublishingChannelExchangeAutoDelete" value="false"/>
<add key="TestPublishingChannelQueueName" value=""/>
<add key="TestPublishingChannelQueueDurable" value="true"/>
<add key="TestPublishingChannelQueueExclusive" value="false"/>
<add key="TestPublishingChannelQueueAutoDelete" value="false"/>
<add key="TestPublishingChannelQueueNoAck" value="false"/>
<add key="TestPublishingChannelQueueBindRoutingKeys" value=""/>
<add key="TestConsumingChannelHostClientServiceName" value="TestConsole"/>
<add key="TestConsumingChannelHostName" value="localhost"/>
<add key="TestConsumingChannelHostPort" value="5672"/>
<add key="TestConsumingChannelHostVirtualHost" value="/prod"/>
<add key="TestConsumingChannelHostUserName" value="guest"/>
<add key="TestConsumingChannelHostPassword" value="guest"/>
<add key="TestConsumingChannelExchangeName" value="test.exchange"/>
<add key="TestConsumingChannelExchangeType" value="fanout"/>
<add key="TestConsumingChannelExchangeDurable" value="false"/>
<add key="TestConsumingChannelExchangeAutoDelete" value="false"/>
<add key="TestConsumingChannelQueueName" value="test.queue"/>
<add key="TestConsumingChannelQueueDurable" value="true"/>
<add key="TestConsumingChannelQueueExclusive" value="false"/>
<add key="TestConsumingChannelQueueAutoDelete" value="false"/>
<add key="TestConsumingChannelQueueNoAck" value="false"/>
<add key="TestConsumingChannelQueueBindRoutingKeys" value=""/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<nlog autoReload="true" throwExceptions="true">
<targets>
<target name="console" type="ColoredConsole" encoding="utf-8" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" useDefaultRowHighlightingRules="true"/>
<target name="file" type="File" fileName="${basedir}/logs/test-${shortdate}.log" layout="${longdate}|${level:uppercase=true}|${logger}|${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="console"/>
<logger name="*" minlevel="Error" writeTo="file"/>
</rules>
</nlog>
</configuration>
以上是关于rabbitMQ学习的主要内容,如果未能解决你的问题,请参考以下文章
rabbitmq学习:rabbitmq之扇形交换机主题交换机