Consumers need to write two consumers
Custom message class
Copy the previous code to modify the message inside the class
name and the name of the top switch statement queue
listening modify the name of the queue of email
SMS receiving end
A copy of the email receiving end is called sms renamed code
name into the message queue of the queue name
Start testing program
Producers first start
after starting the producers sent out five messages
can see our new switch
click switches come in, show two queues bound to
our code Routing Key set is empty
you can see each queue 5 messages
Start consumer, consumers start email
Consumers read email message 5
at this time has no message queue inside
Start SMS consumers
5 also read messages
to sum up
Switch Here bind the two columns
a link which can be built multiple channels.
We initiated two processes accounted for two links
each of which has a channel connection
point to open the first channel. Channel which shows there is a consumer, this is a consumer label.
Consumers label because we specified, then it is a number of
consumers have bound to the queue
to another channel bonding is the SMS queue
Rerun the program producers
Two consumers are respectively received this message 5
Publish and subscribe model can achieve a work queue
Mode work queue is a queue monitor multiple consumers.
We can go to create a queue c3 c1 to monitor queues.
SMS queue has started up
again to start a cell phone text message queue
now have three channels
to start two channels is to monitor text messages
Send message again
Only one listener so received email to five
SMS has two listeners, so the polling way
a listener received a message 3 received two additional one.
Publish and subscribe fully equipped with a work queue model is more powerful than the model work queue