Use of RABBITMQ and web monitoring tools

Source: Internet
Author: User
Tags dotnet rabbitmq

This article was reproduced from: https://www.cnblogs.com/gossip/p/4475978.html

For the Windows installation manual Please refer to:http://www.rabbitmq.com/install-windows-manual.html

I. Documents and Materials

1. Official website: http://www.rabbitmq.com/2. Installation Tutorial: http://www.rabbitmq.com/install-windows.html Second, installation Guide1. Download and follow the OTP (must be installed before installing RABBITMQ server): http://www.erlang.org/download.html
32-bit: OTP 17.5 Windows 32-bit binary file (91.0 MB) 64-bit: OTP 17.5 Windows 64-bit binary file (91.1 MB) 2, download and Ann Install RABBITMQ server:http://www.rabbitmq.com/download.html Select the Windows platform, download it directly from the official link, and load it from GitHub, service starts automatically when installation is complete (services.msc)
3, download and install. NET client: 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 (SELECT Choose the. NET 4.0 version, It can also be downloaded through NuGetthree, command-line tools1. Navigate to RabbitMQ installation directory: Windows 7 CD C:\Program Files (x86) \RABBITMQ Server\rabbitmq_server-3.5.1\sbin Wido         WS Serve cd/d C:\Program Files (x86) \RABBITMQ Server\rabbitmq_server-3.5.1\sbin 2, execute RabbitMQ command-line tool (RABBITMQCTL): RABBITMQCTL-Q Status//print some RABBITMQ service status information, including memory, hard disk, and version information using Erlong rabbitmqctl list_queues//View all teams Column messages Iv. use of C # clients1. Service-side code
Namespace server{class Program {static void Main (string[] args) {var factory = new Conne            Ctionfactory () {HostName = "localhost"}; using (var connection = factory. CreateConnection ()) {using (var channel = connection. Createmodel ()) {//define queue (Hello is queue name) 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) {//accepts the message sent by the client and prints out the var ea = (Basicdelivereventargs) consumer.                         Queue.dequeue (); var BODY = ea.                        Body;     var message = Encoding.UTF8.GetString (body);                   Console.WriteLine ("[x] Received {0}", message); }                }            }        }    }}

2. Client code
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 ())                {                    //define queue (Hello is queue name)                    channel. Queuedeclare ("Hello", False, False, false, NULL);                    Message sent to the queue, containing the timestamp                    string message = "Hello world!" + "_" + DateTime.Now.ToString ();                    var BODY = Encoding.UTF8.GetBytes (message);                    Channel. Basicpublish ("", "Hello", null, body);                    Console.WriteLine ("[x] Sent {0}", message);}}}            

If the client is started before the server is started, the message is stored in the queue, and the DA v. Use of RabbitMQ GUIDs1. A Web management tool (Rabbitmq_management), officially provided       Http://www.rabbitmq.com/management.html 2, after the installation of RABBITMQ, the default is also installed the management tool, execute the command to start Rabbitmq-plugins enable Rabbi Tmq_management (first locate to RABBITMQ installation directory) 3, after launch, directly in the browser address input: http://localhost:15672/account password are: Guest



Six, abnormal problems

1. None of the specified endpoints were reachable

The factory parameters of the production end and the consumer end are unified

var factory = new ConnectionFactory ();
Factory. UserName = Queuesetttiong.username; User name, corresponding to the admin-->user of the management tool
Factory. Password = Queuesetttiong.password; password, corresponding to the admin--> password of the management tool
Factory. HostName = Queuesetttiong.hostname; Local deployment Services can be used directly with hostname
Factory. Port = Amqptcpendpoint.usedefaultport;
Factory. VirtualHost = Queuesetttiong.virtualhost; Use default value: "/"
Factory. Protocol = Protocols.defaultprotocol;

Use of RABBITMQ and web monitoring tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.