Examples of basic concepts and principles of RABBITMQ

Source: Internet
Author: User
Tags rabbitmq

RABBITMQ Basic concepts and principles

1.AMQP, Advanced message Queuing Protocol, is an open standard for application-layer protocols designed for message-oriented middleware.

2.RabbitMQ is an open source AMQP implementation that is written by the server side in Erlang.

3.Channel

Channel is one of the most important interfaces we have with RABBITMQ, and most of our business operations are done in the channel interface, including defining queue, defining exchange, binding queue and exchange, publishing messages, and so on.

4.Exchange(the producer sends messages to Exchange (exchanger), the messages are routed by Exchange to one or more queue (or discarded), RABBITMQ commonly used exchange type has fanout, Direct, topic, headers these four kinds)

5.Queue(internal object of RABBITMQ, for storing messages)

6. Basic working principle

The client (producer) Send Message-->exchange (the switch saves messages to the corresponding Queue by different types)-->queue

The client (consumer) consumes the message in the queue by subscribing.

The above basic concept arrangement comes from RABBITMQ Basic Concept Detailed Introduction

Installing RABBITMQ in a Windows system

1. Download and install Erlang (I'm using the otp_win64_19.3 version)

Download address (select 32 64-bit depending on the operating system)

2. Download the installation Rabbitmq-server (I'm using the rabbitmq-server-3.6.10 version)

Download Address

After the installation, see under the Loading directory

Next use the Enable DOS command

A. CD to Sbin directory, my installation directory is D:\RabbitMQServer\rabbitmq_server-3.6.10\sbin, enter D: Carriage return, CD rabbitmqserver\rabbitmq_ Server-3.6.10\sbin

B. To see if the installation was successful command:rabbitmqctl status

C. Install the management plug-in command:rabbitmq-plugins enable Rabbitmq_management

Successful installation, enter http://127.0.0.1:15672/in the browser

Enter Guest account guest password guest, successful landing in, is not a little excited.

The Guest account is an administrator account and can be added Exchanges,queues,admin. However, we generally do not use the Guest account, continue to use the command to add accounts and permissions.

D: Add User:rabbitmqctl.bat add_user username password

E: Add "Super admin" role: rabbitmqctl.bat set_user_tags username Administrator

MYMQ account is also a super administrator, can access virtual Hosts:no access, you will see that there is no access to the VM, next add the virtual machine.

F: Add virtual machine: rabbitmqctl add_vhost vhostname

The myvhost virtual machine does not have users and then binds the virtual machine to the account.

G: Set virtual machine and user rights:rabbitmqctl set_permissions-p Virtual machine name Account name ". *". * "". * "

H: In habit I generally delete the Guest account:rabbitmqctl.bat delete_user username

OK, re-login to manage the page, everything is normal, then began the actual combat.

Basic use of EASYNETQ

Installing EASYNETQ in the project

EASYNETQ is dependent on rabbitmq.client, so it will be installed in the project.

Publish Publishing messages

Model has a queue attribute that defines the queue name and exchange name. The Publish method is then used to push MSG through the model-specified switch to the specified queue.

Run the code and look at the MQ Administration page.

The model specified switch Testqueue.exchange, type:topic, features:d have been created. d:durable indicates that the switch created by default is persistent .

Because there are no subscription messages, the corresponding queue is not visible in queues.

Subscribe Subscription Message

Why do you want to have a while (true) in the subscription code? is to simulate a console program as a Windows service, because the console program runs a flash and there is no way to actually subscribe to MQ messages.

In actual development, the general use of topself to the console program to publish Windows Services , there is time later to write a study on the Topself blog.

Repeat the publish operation and test the entire process.

Custom Topic

The message is sent to all queue queues that begin with the name test.

Send and Receive

Messages can be sent to the specified queue via send and receive.

Related Article

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.