RabbitMQ instance Tutorial: Java Implementation of Hello RabbitMQ World
RabbitMQ is actually very easy to implement Hello World. Only one server is needed to send messages, and another client can receive messages.
The overall design process is as follows:
The message producer sends Hello messages to the message queue, and the message consumer receives messages f
message queue is obtained. You can configure prefetch_count = 1 on each consumer to tell RabbitMQ not to send new messages when the current message of this consumer is not processed.
Consumer
The producer end remains unchanged.Publish and subscribe messages (publish \ subscribe)
The difference between publishing and subscription is that publishing and subscription will send messages to all subscribers, and the data in the message queue will disappea
Set up a RabbitMq cluster and a rabbitmq Cluster
Lab environment:
The operating system is Centos 7.2.
IP hostName
192.168.190.132 node132
192.168.190.139 node139
192.168.190.140 node140
RabbitMQ Port
4369 (epmd)
5672,567 1 (AMQP 0-9-1 and 1.0 without and with TLS)
25672. this port used by Erlang distribution for inter-node and CLI tools communication and i
machine, you only need to fill in the address or host name.
Next we start to send the message. make sure that the queue that receives the message exists. otherwise, rabbitmq discards the message.
Channel. queue_declare (queue = 'Hello') # create the queue channel hello in RabbitMQ. basic_publish (exchange = '', # use the default
Introduction
Message Queuing now applies a lot to the Internet project, and the next blog post will delve into the implementation of MQ, and in this blog I'll explain how to install MQ under CENTOS7 and the problems that are encountered.
First step: Install Erlang
Because RABBITMQ is written in Erlang language, we first need to install Erlang
RPM-UVH http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpmStep two, install
RabbitMQ + PHP (3) case study and rabbitmq demonstration
Today, we use a simple case to implement the Message Queue running mechanism of RabbitMQ + PHP.
There are two main parts:
1. publisher)
Second: consumer)
(1) Producer (create a rabbit_publisher.php file)
Create a connection --> Create a channel --> Create a switch object --> send a message
$ Conn_args =
RABBITMQ, as a mature enterprise message middleware, realizes the decoupling of interface calls between applications and improves the throughput of the system.1.RABBITMQ Composition
is an open source implementation of Advanced Message Queuing Protocol (AMQP) provided by LShift, written in Erlang, known for its high performance, robustness, and scalability, and therefore inherited these benefits.
A few of the previous tutorials explain how to use rabbitmq, which focuses on spring integrated RABBITMQ.First introduce the configuration file org.springframework.amqp, as follows One: Configure the Consumer and Generator public sectionPort= "${rabbit.port}" username= "${rabbit.username}" password= "${rabbit.password}" virtual-host= "${rabbit.virtualHost} "Channel-cache-size= "/> Two: Configuration Generatorimport resource= "amqp-share.xml"/>
, and MQ follows the specific implementations and products of the AMQP protocol.
Usage Scenarios
In the project, some operations without immediate return and time-consuming are extracted and processed asynchronously, which greatly saves the request response time of the server and improves the throughput of the system.
Meaning
RABBITMQ is a popular open source Message Queuing system, developed in Erlang language.
RabbitMQ original translated 05 -- routing, rabbitmq translated 05 -- Routing
In the previous article, we built a simple log system that can broadcast messages to multiple recipients.
In this article, I will add some functions to make it possible to accept some messages. For example, we only record error messages on disk, at the same time, all messages can be printed to the screen.Bind
In the previous case,
Test environment: VMS00781 VMS00782 VMS00386 (centos5.8)1. Install RABBITMQ Server separately on three machines first2. Read the cookie from one of the nodes and copy it to the other nodes (between the nodes to determine if they can communicate with each other through a cookie)Either of the two can:sudo vim/var/lib/rabbitmq/.erlang.cookiesudo vim $HOME/.erlang.cookie3. Start nodes individuallysudo service
HelloWorld
Brief introduction
RabbitMQ: Accepts message re-delivery messages, which can be treated as a "post office." The sender and receiver interact through the queue, the size of the queue can be considered unlimited, multiple senders can take place to a queue, and multiple receivers can accept messages from one queue.
Code
The protocol used by RABBITMQ is AMQP, and the recommended client for Python is
What messaging scenarios are supported by AMQP and RabbitMQ?
AMQP is a very general system that can be configured to cover a great variety of messaging middleware use-cases. For example:
Point-to-point communicationOne of the simplest and most common scenarios is for a message producer to transmit a message addressed to a participant message consumer. AMQP covers this scenario by allowing queues to be named and to be bound to a "direct"
an intermediary agent , the queue information through consul can be a timed cache, and such as the queue of user name password such information through the business service configuration is not easy to maintain, Business services are acquired through the SDK directly through consul, and dependencies can become slightly more complex. Through the RABBITMQ API can also dynamically get the queue of cluster node information, permissions information, etc.,
();
})();
This is an echo client, which comes in, prints out, and waits silently for the next message. If the message is quit, then graceful exit ~Where the code creates a persistent queue:moneyqueue, the queue is automatically bound to the default Exchange, which is provided by RMQ, so it's persistent, so there's no problem.Because this is just a consumer, unable to work alone, to verify, you can send messages through the RMQ Administration page.
://www.oschina.net/news/66104/rabbitmq-3-5-5-rc2?utm_source=tuicoolRABBITMQ Common CommandsRabbitmq-server Start or service rabbitmq-server start #启动rabbitmqRabbitmqctl list_exchangesRabbitmqctl list_bindingsRabbitmqctl list_queues #分别查看当前系统种存在的Exchange和Exchange上绑定的Queue信息.Rabbitmqctl Status #查看运行信息Rabbitmqctl Stop #停止
RABBITMQ Introduction 1, What is RABBITMQ?
MQ is all called MessageQueue, and Message Queuing (MQ) is an application-to-application communication method. Applications communicate by writing and retrieving data (messages) for applications that enter and leave the queue, without requiring a private connection to link them.RabbitMQ is an open-source implementation of the AMQP (Advanced Message Queuing
RabbitMQ installation process and RabbitMQ Installation Process
Original article reprinted please indicate the source: @ cosi, http://zeeman.cnblogs.com
Some installation tutorials on the Internet are cumbersome. In fact, you only need two RPM packages to complete the deployment of one instance in a few minutes.
PreparationDownload Erlang package: http://www.rabbitmq.com/releases/erlang/Download
This is a creation in
Article, where the information may have evolved or changed.
1: Environment Selection
The system for Ubuntu 15.04, I installed in the virtual machine inside the
2:rabbitmq
TABBITMQ 3.5.4 Download url:http://www.rabbitmq.com/
3: Installation
In the Ubuntu environment, it is recommended that you download the Deb installer directly, install it directly in Ubuntu package management, and install other dependent packages
4: Start
If the
(1) Download RABBITMQ serverDownload the latest stable version from the RABBITMQ website. Currently the latest version is 3.5.1.(2) Remove the old version of RABBITMQ.If you have previously installed older versions, or want to upgrade your Erlang VMs from 32-bit to 64-bit, you will need to manually uninstall the RABBITMQ server. Because the old service is not sto
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.