Stage 5 3. Micro Services [studies] _day05 online messaging middleware RabbitMQ_8.RabbitMQ Research - operating mode - Post subscription model - Producer




Publish / subscribe: subscribe model release


issued subscription model:
1, every consumer monitor its own queue.
2, the message to the producer Broker, the switch forwards the message to each queue bind this switch, each switch binding queues will receive
the message

among a plurality of switches

a message producer to a first switch , the switch sends a message to each queue. Each queue has a different consumer listening

implements a news release more consumers can receive this news
if the following queue to get rid of. So part of the red circle and mode of operation is the same. Although there is no work confront switch will have a default switch.
So Posted subscription feature work queue can be achieved. But it is more powerful than the work queue, it can implement multiple consumers at the same time to accept the same message

have a test

Case:
user notification when a user recharge or transfer successfully complete the system informs the user that there are many ways to inform the way text messaging, e-mail.
Represent the two message queues sms and email messages is

defined a new producer

to copy the original code to a new class of logic which


has a switch and two queues

in the queue when the statement, two statements queues

Switch statement


Ctrl + T to find the class that implements

this method is that the parameters of

the replacement machine has a lot of constant type

of several types

Switch queues and establish a binding



There are a lot of overloads




binding text message queue.

Send a message

5 each message is sent

the first parameter is a switch. The second parameter is set to null routing key,

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11621001.html