JMS Interview Questions

What Is Messaging?

Messaging is a method of communication between software components or applications. A messaging system is a peer-to-peer facility: A messaging

client can send messages to, and receive messages from, any other client. Each client connects to a messaging agent that provides facilities for creating, sending,

receiving, and reading messages.
Messaging enables distributed communication that is loosely coupled. A component sends a message to a destination, and the recipient can retrieve

the message from the destination. However, the sender and the receiver do not have to be available at the same time in order to communicate. In fact, the sender does

not need to know anything about the receiver; nor does the receiver need to know anything about the sender. The sender and the receiver need to know only what message

format and what destination to use. In this respect, messaging differs from tightly coupled technologies, such as Remote Method Invocation (RMI), which require an

application to know a remote application’s methods.
Messaging also differs from electronic mail (e-mail), which is a method of communication between people or between software applications and

people. Messaging is used for communication between software applications or software components.Messaging is a mechanism by which data can be passed from one

application to another application.

Explain the role of the JMS Provider ?

The JMS provider handles security of the messages, data conversion and the client triggering. The JMS provider specifies the level of encryption

and the security level of the message, the best data type for the non-JMS client.

What is the difference between Java Mail and JMS Queue?

JMS is the ideal high-performance messaging platform for intrabusiness messaging, with full programmatic control over quality of service and

delivery options.
JavaMail provides lowest common denominator, slow, but human-readable messaging using infrastructure already available on virtually every computing


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 is recommended to use XAResource API.

What is synchronous messaging?

Synchronous messaging involves a client that waits for the server to respond to a message. So if one end is down the entire communication will


How does a typical client perform the communication?

1. Use JNDI to locate administrative objects.
2. Locate a single ConnectionFactory object.
3. Locate one or more Destination objects.
4. Use the ConnectionFactory to create a JMS Connection.
5. Use the Connection to create one or more Session(s).
6. Use a Session and the Destinations to create the MessageProducers and MessageConsumers needed.
7. Perform your communication.