Python Learning notes--pick one

Source: Internet
Author: User
Tags rabbitmq

differences between co-process and io multiplexing

all inherit the same class libevent.so

The process can also be understood as IO multiplexing

Io multiplexing is a bit more inclined to IO

The co-process is a more upper-level package a shift in favor of a function.

RabbitMQ Message Queuing

1. Single send single receive

2. single send multi-receive

3. broadcast , subscription mode

4. Selective reception of messages Routing (send and receive by route)

5. more granular message filtering Topics (send and receive by topic)

6.RPC

Process Queue:

Interacts with child processes in the parent process, or with multiple child processes under the same parent process.

RABBITMQ: Two separate programs or programs in Java and Python communication, different machine communication, then need an intermediary agent. RabbitMQ.

Why have the producers already declared the pipeline and consumers have to declare it again?

If the producer starts first and the pipeline has been created, there will be no problem.

If the consumer starts first, does not declare the pipeline, will error

RABBITMQ installed in Windows

Producers

Consumers

Consumer's callback function

CH represents the memory object of the pipeline

Methon Queue Information

Body Data

Data processing in this

RABBITMQ consumer data is the polling method

If you start a 3 consumer a B C

producer 1 production data, a received

producer first 2 production data, B received

producer first 3 production data, C received

producer 4 production data, a received

So the cycle, fair to the message to each consumer, to achieve load balance

Note that there are parameter no_ack

True indicates that the consumer does not respond to the producer regardless of whether the message has been processed or not, and does not care about the message.

False means default is false, message processing is finished to producer response

RABBITMQ deletes the message according to the consumer's response, and if the message is processed in half and the consumer hangs up, then

Messages are not deleted but sent to other consumers.

Under WinDOS, use the following command to find the current queue and the number of messages in it

Data persistence

When you create a pipeline set the Durable=true persistence queue to be written on both the producer and the server

settings such as persistent message producers when sending messages

Complete as:

Load balancing for RABBITMQ

on the consumer side Set

after this setting if the current consumer processes more than 1 messages , it will be forwarded to other consumers. All consumers are set up to handle the message fast consumers, processing a message will be processed, processing slow will be the current message processing, and then receive the next message. In this way, we are responsible for balance.

Set Broadcast mode Message Subscription

A subscription publication can send a message to a consumer that binds to the same forwarder at the same time, but the message is like a broadcast, although you're not listening. However, the message is sent normally, and the missed message will not appear again.

Producers

Exchange= "Log" is a forwarder

Type= ' Fanout '

No more statement queue required in consumer statement queue

Consumers:

Sys.argv[]Get External parameters

Like saving a test.py.

Import Sys

A=SYS.ARGV[1]

Print (a)

Add a parameter to the runtime what results are as follows

Specific explanation: E:\python Learning \ Learning Web page \python sys.argv[] The use of concise explanation

the exit of Sys.exit () is elegant, and a Systemexit exception is thrown after the call to catch this exception , execute the code in exception handling

Os._exit () exits the Python interpreter directly, and the remaining statements do not execute

Exit (0): no error exits
Exit (1): There was an error exiting

selective acceptance of messages   

Producers are required to send messages

test_p.py Error Helle_word

test_p.py (producer's file) error (plus type) helle_word (content)

Consumers are sending messages that require

test_c.py Error Info

test_c.py (Consumer's file) Error info (plus type, can write a few more)

of course You can change the error to SB, just the type of producer and consumer. If you don't, you won't receive the message.

Python Learning notes--pick one

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.