JMS Interview Questions and Answers
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. Does JMS specification define transactions?
JMS specification defines a transaction mechanisms allowing clients to send and receive groups of logically bounded messages as a single unit of information. A Session may be marked as transacted. It means that all messages sent in a session are considered as parts of a transaction. A set of messages can be committed (commit() method) or rolled back (rollback() method). If a provider supports distributed transactions, it's recommended to use XAResource API.
Ques 2. What is the difference between Point to Point and Publish/Subscribe?
Point-to-point (P2P)
In point-to-point, messages are sent via queues. Messages are put onto the queues by the message producers (the clients). The message consumer is responsible for pulling the message from the queue. Point-to-point is typically used when a given message must be processed (received) only once by a given consumer. In this way, there is only one consumer of the given message.
Publish-and-subscribe (pub/sub)
In publish-and-subscribe, messages are sent through topics. Messages are published to topics by the message producers. The messages may be received by any consumers that subscribe to the given topic. In this way, a message may be received, or processed, by multiple consumers.
Ques 3. How does the Application server handle the JMS Connection?
1. App server creates the server session and stores them in a pool.
2. Connection consumer uses the server session to put messages in the session of the JMS.
3. Server session is the one that spawns the JMS session.
4. Applications written by Application programmers creates the message listener.
Most helpful rated by users:
- How many messaging models do JMS provide for and what are they?
- What is JMS (Java Messaging Service)?
- How the JMS is different from RPC?
- What are the different types of messages available in the JMS API?
- What are the basic advantages of JMS?