<SimplePubSubPattern><CompetingPattern>
In Broadcasting pattern, a producer produces message to topic and any number of consumers can consume the message.
Why Do we need Broadcasting pub/sub pattern?
For example, we placed an order in an online app, we will immediately receive order confirmed message, but at the backend our order is published to topic which will be consumed by the dealer/seller and other sources inside the network of app to track the ordered items. Hence Broadcasting of message (i,e. order) is happening in this scenario.
Uses Case for Demo (Video) Broadcasting Pattern
Here Producer produces message to topic, and it's consumed by both ConsumerA and ConsumerB
Demo To create Free Kafka with Confluent Cloud
please follow the steps in Video if you don’t have Kafka in handy for demo, where you can create Kafka topic with Confluent. Based on the link I have created Kafka cloud account for bootstrap server, username and password for my publish and consume connectors.
Anypoint Studio Flow
point to remember in while achieving the above pattern, both Message listeners should have different Consumer Configuration but should listen to same topic.
(1) Configure message to publish to kafka
(2) Configuration to Publish Message to Kafka
topic Name: topic_1
Consumer-A flow
(3a) Once Message is published Successfully, we can Consume the Message as below
topic: topic_1
(3b) After Listening from Message Listener, we can consume as below.
Consumer-B flow
(4a) Once Message is published Successfully, we can Consume the Message as below
topic: topic_1
(4b) After Listening from Message Listener, we can consume as below.
Logger to log in console
Response After consumed
Youtube Links:
Demo on Apache Kafka Pub/Sub Broadcasting pattern with Mule4
Demo To create Free Kafka with Confluent Cloud
clonfluentPage for more information
For the above example please refer my git Repo
git repo: racs07/demo-kafka (github.com)
git-clone: https://github.com/racs07/demo-kafka.git