I am studying for the Spring Core certification and I have some doubt about how JMS works and about how Spring handle it.
So I know that the JMS Core Components are:
- Message
- Destination
- Connection
- Session
- MessageProducer
- MessageConsumer
From what I have understand a Message is what is send and shared with other entities (other products that have to consume this data) and a message can have differents shapes: TextMessage, ObjectMessage, MapMessage, BytesMessage and StreamMessage.
Ok, from what I understand the Destination component of the JMS Core Components defines who receives messages and the logic for dispatching messages.
So I know that I have 2 kinds of destinations that are:
Queue: that define a point to point message. From what I have understand I can have some Message Producer that put the generated messages into a queue and then I have some MessageConsumer that consume message. Each message can be consumed by a single MessageConsumer.
Now my doubt is: a MessageConsumer consume message putted into the queue by a specific MessageProducer (there is something like a 1 to 1 relationship between MessageConsumer and MessageProducer) or a MessageProducer put an id related to the specific MessageConsumer that have to read the message that it put into the queue?
So for example, in the first case if I have 2 MessageProducer respectivelly named Producer-1 and Producer-2 I need to have 2 MessageConsumer named Consumer-1 and Consumer-2 where Consumer-1 consume messages produced from Producer-1 and Consumer-2 consume messages produced from **Producer-2).
Instead in the second case the Consumer-1 can consum messages produced by from both Producer-1 and Produer-2 because the MessageProducer put a message in the queue specifying who is the MessageConsumer that have to consume the message.
How exactly works? What is the correct logic?