The document discusses Java Message Service (JMS) which provides a common interface for sending messages between two or more clients. It covers JMS concepts like producers, consumers, queues and topics. It also describes the different message types and the typical algorithm for using JMS including obtaining connections and creating producers/consumers. Additionally, it shows how to implement synchronous and asynchronous messaging and how to use JMS within Spring applications including configuration, message listeners and templates.
5. Message types
JMS specification provides standard implementations of javax.jms.Message:
1. javax.jms.BytesMessage - array of bytes
2. javax.jms.MapMessage - key-value pairs
3. javax.jms.ObjectMessage - serialized Java object
4. javax.jms.StreamMessage - stream of Java primitive values
5. javax.jms.TextMessage - Java String object (used for XML)
6. The working algorithm with JMS
1. Obtain a javax.jms.ConnectionFactory using a JNDI lookup. (The default ConnectionFactory
names are different depending on the JMS provider.)
2. Obtain a javax.jms.Connection from the ConnectionFactory.
3. Obtain a javax.jms.Session from the Connection.
4. Create a javax.jms.MessageProducer or javax.jms.MessageConsumer from the Session.
5. For a MessageProducer, send the message, or for a MessageConsumer, receive the message
(synchronous) or set the message listener (asynchronous).
6. Start the Connection to start message delivery.
7. Ultimately close the Connection.