RABBITMQ in Window Construction

Source: Internet
Author: User

RabbitMq window set up the process, some of the internet is not quite clear, so personally fencing the test process, referring to a lot of people's information, thank you to the great God's valuable information
The first step: Install RABBITMQ operating environment, similar to a virtual machine Dongdong
1.otp_win32_19.0.exe:https://www.erlang.org/32-bit and 64-bit according to the personal system installation is different, this address is foreign, seemingly fq (forwindows)
2.rabbitmq-server-3.2.3.exe:http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.3/ Rabbitmq-server-3.2.3.exe (Rabbit MQ server Windows Installer)

You have to go to your computer when you're done here. Setup environment variables, advanced system settings, Control Panel, start
Must be a system variable, add variable name: Erlang_home variable Value: C:\Program Files (x86) \erl8.0---------Description, this path is for you to install ERLANG this thing is installed by default C drive
Otherwise it will be detours, I was not added to the system variable, I am, I killed two days, I checked a lot of information and did not speak clear

The default installed rabbit MQ listening port is 5672

With the Rabbit MQ Management plug-in, you can better visualize the status of your rabbit MQ server instances.
First you can activate it at the command line using the following command:
Do not self-cmd CP menu directory to find Kazakhstan, install the above 2, there will be the following, open it automatically opened


C:\Program Files (x86) \RABBITMQ server\rabbitmq_server-3.2.3\sbin\------
Then write the commands behind the bars.
If the activation management interface take this to replace the horizontal bar: Rabbitmq-plugins.bat Enable Rabbitmq_management

To restart the service to take effect, you can perform

net stop RabbitMQ && net start RabbitMQ

Step Two: We use the RABBITMQCTL console command to create a user and password, set permissions, and so on
1. To view the list of RABBITMQ users, you can see that only one guest permission is Administrator
C:\Program Files (x86) \rabbitmq Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat list_users
Listing Users ...
Guest [Administrator]
. .. done.

2. Add Users
C:\Program Files (x86) \RABBITMQ Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat Add_user Guan 1230
Creating User "Guan" ...
. .. done.
view users, have been added, the permissions are empty
C:\Program Files (x86) \rabbitmq Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat list_users
Listing Users ...
Guan []
Guest [Administrator]
. .. done.
then set permissions for the user you just added
C:\Program Files (x86) \RABBITMQ Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat Set_user_tags Guan Administrator
Setting tags for the user "Guan" to [Administrator] ...
. .. done.

C:\Program Files (x86) \RABBITMQ Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat set_permissions-p/Guan ". * " ".*" ".*"
Setting permissions for the user "Guan" in Vhost "/" ...
. .. done.

View the user who just added the settings, Guan This user has set permissions Administrator
C:\Program Files (x86) \rabbitmq Server\rabbitmq_server-3.2.3\sbin>rabbitmqctl.bat list_users
Listing Users ...
Guan [Administrator]
Guest [Administrator]
. .. done.
Step three: Use the browser to open the http://localhost:15672 Access Rabbit MQ Management console, using the account you just created login system: Management interface


Fourth step: Code sends a message to simulate sending 10 messages into RABBITMQ, console, reference RabbitMQ.Client.dll

Static voidMain (string[] args) {varFactory =NewConnectionFactory (); factory. HostName="localhost"; factory. UserName="Guan"; factory. Password="zj1230";using(varConnection =Factory. CreateConnection ()) {using(varChannel =connection. Createmodel ()) {channel. Queuedeclare ("Hello",false,false,false,NULL); for(inti =0; I <Ten; i++){stringMessage ="Hello World"+i;varBODY =Encoding.UTF8.GetBytes (message); channel. Basicpublish ("","Hello",NULL, body); Console.WriteLine ("set {0}", message);}}} Console.ReadLine ();}

Here to talk about the problem I encountered, not the code problem, is a reference to the issue, be sure to note the version, RabbitMQ.Client.dll version of the latest net4.5, if you use the vs210
Just loaded. net4.0 that he would have been connected unsuccessfully, prompted what Address.ipv6 error, so note the version and your vs counterpart OH
Send complete, can access http://localhost:15672, just see the queue has 10 messages,
The fifth step: that is the receiving end, also use a console, accept

Static voidMain (string[] args) {varFactory =NewConnectionFactory (); factory. HostName="localhost"; factory. UserName="Guan"; factory. Password="zj1230";using(varConnection =Factory. CreateConnection ()) {using(varChannel =connection. Createmodel ()) {channel. Queuedeclare ("Hello",false,false,false,NULL);varConsumer =NewQueueingbasicconsumer (channel); channel. Basicconsume ("Hello",true, consumer); Console.WriteLine ("waiting for message."); while(true){varEA =(Basicdelivereventargs) consumer. Queue.dequeue ();varBODY =ea. Body;varMessage =Encoding.UTF8.GetString (body); Console.WriteLine ("Received {0}", message); }}}

You can see the 10 message data you just sent on the console.
Go to visit http://localhost:15672, go to the queue message, has been displayed as 0

As for linnux deployment below, and then again, there are clusters, for the time being, please refer to other information on the Internet, write this is not for others, just to remember how to configure, but also convenient for some of the entry to learn the reference bar,

RABBITMQ in Window Construction

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.