DC 9225 Exp4
DC 9225 Exp4
4
Practical No:
Evaluation:
RabbitMQ Model:
RabbitMQ is one of the most widely used message brokers, it acts as the message
broker,
“the mailman”, a microservice architecture needs.
RabbitMQ consists of:
1. producer — the client that creates a message
2. consumer — receives a message
3. queue — stores messages
4. exchange — enables to route messages and send them to queues
Here too, we create connection and channel the same way as in our publisher.js
program
o Then we write functionality to consume the messages already present in the
queue
o Let us say that our consumer only consumes message number 22. Hence, if the
queue has a message number 22, it will be consumed by the consumer and an
acknowledgement will be passed to the RabbitMQ server. Subsequently the
message
number 22 will be dequeued
Step 4: Testing our system
Running Producer – publisher.js
Publish job 10
Publish job 20
Publish job 35
Conclusion:
o Message queueing systems, its need, architecture, and implementation were
understood
o A simple message queueing system was designed and executed using RabbitMQ
message broker.
Postlab Questions:
1.What is message Queueing?
1. Asynchronous Communication: Message queuing enables asynchronous
communication between components. Senders and receivers do not need to
interact directly or be active at the same time. Messages are placed in the
queue by the sender and processed by the receiver whenever it's ready.
2. Decoupling: Message queuing decouples the producers (senders) and
consumers (receivers) of messages. This means that components can send
messages to a queue without needing to know the details of who will
consume them or when they will be processed.
3. Reliability: Message queues often provide mechanisms for ensuring reliable
message delivery, such as persistence and acknowledgment mechanisms.
Messages are typically stored persistently in the queue until they are
successfully processed by a consumer.
4. Scalability: Message queuing systems can handle large volumes of
messages and scale horizontally to accommodate increased loads. They can
distribute messages across multiple queues and consumers to balance the
workload.
5. Fault Tolerance: Message queuing systems are designed to be fault-
tolerant. They can handle failures in producers, consumers, or the messaging
infrastructure itself by providing features like message replication, failover
mechanisms, and message retry policies.
6. Integration: Message queuing is commonly used for integrating disparate
systems, allowing them to communicate and exchange data in a standardized
and reliable manner. It's often used in microservices architectures, where
different services need to communicate asynchronously.