Details on the use of RabbitMQ. NET message queues and the use of rabbitmq
This example shares the usage of RabbitMQ. NET message queue for your reference. The details are as follows:
First download the installation package. All environments are win7 64-bit:Download otp_win64_19.0.exe and
long as the node list contains itself, it becomes a disk node. In a RABBITMQ cluster, at least one disk node must exist.
Now execute the script on the master node, wait for execution, and then execute the Service node script, not in the wrong order Oh ~
After execution, view the node status on each machine 1./rabbitmqctl cluster_status
You will see the following separately
RABBITMQ1 View cluster status Res
, thereby controlling the duration of the task with Time.sleep (). one point (.) will take 1 seconds. For example, "Hello ..." can take 3 seconds.
3. Work QueuesWe need to modify on the basis of Hello World, combined with the previous chapter of the explanation of the parameters, one by one processing, we first introduce the following key words, and finally the summary and integration.
Cyclic schedulingOne advantage of working with a work queue is that it can process
Use Python to learn RabbitMQ message queues,
RabbitMQ can be used as a message proxy. The core principle of RabbitMQ is very simple: receiving and sending messages. You can think of it as a post office: We put the mail into the mailbox, the postman will deliver the mail to your recipient.
queue is often busy, and the other queue is very easy. RABBITMQ does not know that these are still evenly distributed messages.The reason for this is that RABBITMQ only forwards messages when the message arrives at the exit of the queue, and it does not care about the number of messages that have not reached the message consumer. It just blindly sends odd messages to a consumer, even to another consumer.Th
, producer, rate, etc.) Flow Control Redis: Not available, you need to implement it yourselfRabbitMQ: Server overload situation, the producer rate will be limited to ensure service reliability Access Team performance For RABBITMQ and Redis on-board and out-of-team operations, each execution 1 million times, every 100,000 times the execution time is recorded.The test data is divided into 128Bytes, 512Bytes, 1K and 10K four different sizes of data.Exper
1.1 Introduction to the contents of this sectionThis part we are going to send a message to multiple consumer, which is called "Publish/subscribe"The way we do this is the sending side, sending a message, and at the same time, multiple receivers will receive the message and print it on the screen at the same time.1.2exchange IntroductionIn the previous blog post, we explained that the sender sends a message to the message queue and the receiving side obtains the message from the message queue. N
controlRedis: Not available, you need to implement it yourselfRabbitMQ: Server overload situation, the producer rate will be limited to ensure service reliabilityAccess Team performanceFor RABBITMQ and Redis on-board and out-of-team operations, each execution 1 million times, every 100,000 times the execution time is recorded.The test data is divided into 128Bytes, 512Bytes, 1K and 10K four different sizes of data.Experiments show that:In the queue,
2. Workqueues Task Force column mode:
On the previous blog we completed a simple send and receive message program for the claims queue. Below we will create a work queue to distribute time-consuming tasks to multiple workers (consumer).
Today we look at the Work queue (aka: Task queue). The main purpose is to avoid the immediate task of being a resource-intensive but waiting to be completed. Instead, we do task scheduling: encapsulate the task as a message and send it to the queue. The worker
(Body.count (b'.')) Print("[x] done") Ch.basic_ack (Delivery_tag=method.delivery_tag) Channel.basic_qos (Prefetch_count=1) Channel.basic_consume (callback, queue='Task_queue') channel.start_consuming ()Code explanationChannel.queue_declare (queue='task_queue', durable=True) tells Rabbitmq never to lose the queue, Even if the RABBITMQ server is hung out. defCallback (ch, method, properties, body):Print "
. Producers only need to post messages, without having to worry about which subscribers are consuming messages.
Fault peaks and flow control: when the upstream and downstream systems have different processing power, they need to be like a message queue to separate the two systems as buffers.
The current mainstream Message Queuing software, mainly in the following types:
The simplest message queue in Activemq:java is the implementation of JMS, which does not specify the ordering
The list of the most common linear structures we have in algorithmic design is just a few:1. Arrays:The array should be one of my most common. His storage address is continuous, that is, when we open an array, we will assign him a continuous address. Since his address is continuous, it is very fast to find the element when we know he is subscript.2. Linked list:The position of the elements in the list is no
StackA stack is a last-in, first-out (LIFO) data structure. You can add an object to the stack by using the push operation, or you can return and delete the top object by using a pop operation.The following is the code for the list emulation stack:Here is the result of the operation:QueueA queue is a first in, Out (FIFO) data structureThe following is the code for the list emulation queue:here is the result
;>>>>> from collections import deque>>> queue = Deque (["Eric", "John", "Michael"]) >>> Queue.append ("Terry") # Terry Arrives>>> queue.append ("Graham") # Graham Arrives>>> Queue.popleft () # The first to arrive now leaves ' Eric ' >>> queue.popleft () # The second-arrive now Leav Es ' John ' >>> queue # Remaining queue in order of Arrivaldeque ([' Michael ', ' Terry ', ' Graham '])Python stacks and
Self._count-= 1 return Node.item # Returns an iterator For traversing the list of items Def __iter__ (self): return _linklistqueueiterator (self._qhead) # Private Storag E class for creating the linked list Nodesclass _linklistqueuenode (object): Def __init__ (self, item): Self.item = Item Self.next = none# defines a linked list iterator class _linklistqueueiter
FIFO (First-in, first-out, FIFO) queue: Deletes those elements that remain in the queue for the longest time when a delete operation is performed.The FIFO queue is an ADT that contains two basic operations: inserting (Put) a new item, deleting (GET) an item that was first inserted.First, the list of FIFO queue implementationThe difference between a FIFO queue and the lower stack is that the insertion of the new item is at the tail, not the head. So th
The dual-ended queue supports thread safety, adding and removing at either end of the two ends, with a time complexity of O (1). Access to index access at both ends, with a time complexity of O (1). The time complexity of accessing intermediate elements is O (n). Random access or take a listList: Time complexity O (n)Implementation of the double-ended queue:Class Deque:# Analog dual-ended queuedef __init__ (self):Self.items = []def isEmpty (self):return self.items = = []def addfront (Self,item):
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.