anypoint mq (mulesoft) pub sub model
TRANSCRIPT
Anypoint MQ – Pub Sub Model
- Karthik Selvaraj
AgendaWhat’s Pub Sub ModelBusiness Use case of Pub Sub
ModelPub Sub with Anypoint MQPub Sub Operations
Pub Sub ModelPublish–Subscribe is a messaging pattern where senders
of messages(Publishers) do not program the messages to be sent directly to specific receivers (subscribers), but instead publish the messages with a topic without knowledge of their subscribers. Similarly, subscribers express interest to one or more topics and only receive messages that are of interest, without knowledge of who the publishers of the messages are.
Pub Sub – Use caseLet’s consider a mobile app named SportsNewsZX, which
provides customised sports news for customers based on their interest.
Currently their operations provide update for Cricket, Basket ball, Golf and Rugby.
Their customers are Kumar,John,Mary and Asif. Each person has their own interest.Kumar needs only cricket updates.John loves Rubgy and golf.Mary wants only Basket Ball updates.Asif is interested in all sports.
Pub Sub – Use case
SportsNewsZX
PUBLISH
Subscriber List
GolfJohnAsif
RugbyJohnAsif
CricketKumar
Asif
Basket BallAsif
Mary
Customers
Kumar
Asif
John
Mary
Pub Sub – Use caseSo SportsNewsZX don’t directly send the messages to the
customers, instead they publish a message with a topic tagged among the four sports topic (Cricket, basket ball, golf and Rubgy).
A subscriber list is maintained and if the customers need updates on any topic, they can subscribe to it to get updates.
A subscriber can unsubscribe from a topic as well.In this scenario this approach Pub Sub model is best suited
and it provides assured delivery of message for the customers who have subscribed.
Pub Sub with Anypoint MQTo achieve this model with Anypoint
MQ, we use the exchange component. A queue is created for each customer.An exchange is created for each sports
topic.
Creating a Queue – Anypoint MQ
Creating a Queue – Anypoint MQ
Creating a Queue – Anypoint MQ
Creating a Queue – Anypoint MQRepeat the same process and create the
queue for all customers.Once created , we need to create
exchange for each sports topic as well.
Creating an Exchange– Anypoint MQ
Creating an Exchange – Anypoint MQ
Creating an Exchange – Anypoint MQ
Creating an Exchange – Anypoint MQCreate the Exchange and select the
queue/customers who are interested in those specific sports topics.
Repeat the same and create exchange for all other sport topics as well.
Creating an Exchange – Anypoint MQ
Sending a Message – Anypoint MQTo send a message for a sport topic, click
the exchange for the particular news to be published.
In this example we can publish a cricket message.
Sending a Message – Anypoint MQ
Sending a Message – Anypoint MQ
Sending a Message – Anypoint MQ
Sending a Message – Anypoint MQ
Sending a Message – Anypoint MQ
Sending a Message – Anypoint MQ
Reading a Message – Anypoint MQTo read a message from a queue, click
the queue and select message browser option to see the messages.
Then, select get messages option.Click the ID column to view the message
content.
Reading a Message – Anypoint MQ
Reading a Message – Anypoint MQ
Reading a Message – Anypoint MQ
Referencehttps://docs.mulesoft.com/anypoint-mq/mq-understandinghttps://docs.mulesoft.com/anypoint-mq/mq-tutorialhttps://en.wikipedia.org/wiki/Message_queuing_servicehttps://docs.mulesoft.com/anypoint-mq/mq-ack-modehttps://anypoint.mulesoft.com/https://docs.mulesoft.com/release-notes/mq-release-noteshttps://docs.mulesoft.com/release-notes/mq-connector-rele
ase-notes
Referencehttps://docs.mulesoft.com/anypoint-mq/mq-ack-modehttps://docs.mulesoft.com/anypoint-mq/mq-faqhttps://docs.mulesoft.com/anypoint-mq/mq-apishttps://docs.mulesoft.com/release-notes/anypoint-studiohttps://
en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern
Pub Sub - Anypoint MQ
Thank You