Point to Point Messaging Model is a messaging paradigm supported by JMS (Java Message Service). Point to Point Messaging Model is called as P2P model in short. It is intended to provide asynchronous message transmission between sender and receiver using queues. In this article, lets discuss about Point to Point Messaging Model Architecture in detail.
In Point to Point Messaging Model, the components are:
- Destination: Queue
- JMS Producer: Sender
- JMS Consumer: Receiver
Point to Point Messaging Model Architecture
In Point to Point Messaging Model, JMS Sender and JMS Receiver will be configured to a Queue. JMS Sender will send a message to the JMS Receiver through Queue. JMS Receiver will receive the message from the Queue and read it. The Point to Point Messaging Model architecture is diagrammatically represented below:
Also, what will happen if the JMS Receiver is not active or alive when the JMS Sender sends the message? Even in this case, message transmission will happen successfully. If the Receiver is not available, the Queue will store the message until the Receiver becomes available to receive the message. This is because Point to Point Messaging Model does not enforce any time line dependency between the Sender and Receiver.
Possible Ways to Implement Point to Point Messaging Model Architecture
Point to Point Messaging Model Architecture can be implemented in the following ways:
- Single sender and single receiver connected to a queue
- Single sender and several receivers connected to a queue
- Several senders and single receiver connected to a queue
- Several senders and several receivers connected to a queue
Any number of Senders and Receivers can be configured to a Queue as listed above, but the JMS Message sent by one Sender can be received by only one Receiver. This is because Point to Point establishes a 1 to 1 relationship between the Sender and Receiver. Thus in Point to Point messaging model, message from one sender cannot be transmitted to multiple receivers.