Top 40 Java Message Service (JMS) Interview Questions You Must Prepare 27.Jul.2024

Q1. Does Jms Specification Define Tractions? Queue

JMS specification defines a traction mechanisms allowing clients to send and receive groups of logically bounded messages as a single unit of information. A Session may be marked as tracted. It me that all messages sent in a session are considered as parts of a traction. A set of messages can be committed (commit() method) or rolled back (rollback() method). If a provider supports distributed tractions, it's recommended to use XAResource API. 

 

Q2. Give An Example Of Using Point To Point Model In Jms?

Example for point to point model, would be a print out. When you select a print-out option, your system sends the message to the server, and once the print-out is taken out, again this server will send the message back to you. Point to point model is used, when the information is specific to a single client.

Q3. What Is Publish/subscribe Messaging?

With publish/subscribe message passing the sending application/client establishes a named topic in the JMS broker/server and publishes messages to this queue. The receiving clients register (specifically, subscribe) via the broker to messages by topic; every subscriber to a topic receives each message published to that topic. There is a one-to-many relationship between the publishing client and the subscribing clients. 

Q4. 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. 

Q5. For Jms-enabled Application, What Are The Core Jms-related Objects Required?

The core JMS-related objects that are required are –
•The connection object
•One or more sessions within a connection that provides a context for message sending and receiving.
•A topic or queue object within a session representing the destination within the message broker.
•Appropriate sender or publisher or receiver within a session.

Q6. What Is Jms Administered Object?

JMS administered object is a pre-configured JMS object that is created by an administrator for the use of JMS clients and placed in JNDI namespace.

Q7. What Is Jms?

JMS me Java Messaging Service.  It is the new standard for inter client communication. It allows the J2EE application component to create, send, read and receive the messages.

Q8. Which Models Are Supported By Jms? Please, Explain Them.

Publish/subscribe (pub/sub). This model allows a client (publisher) to send messages to a JMS topic. These messages are retrieved by other clients (subscribers) (it may happen so that a topic has no subscribers) asynchronously. Pub/sub model requires a broker distributing messages to different consumers. 

Q9. What Is The Publish-and-subscribe Model In Jms?

A publish-subscribe model is based on the message topic concept: Publishers send messages in a topic, and all subscribers of the given topic receive these messages. 

Q10. What Is A Jms Client?

JMS client is a language program that sends or receives messages.

Q11. How Jms Is Different From Rpc?

In RPC the method invoker waits for the method to finish execution and return the control back to the invoker. Thus it is completely synchronous in nature. While in JMS the message sender just sends the message to the destination and continues it's own processing. The sender does not wait for the receiver to respond. This is asynchronous behavior. 

Q12. How Does A Typical Client Perform The Communication? Queue

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

Q13. What Is The Jms Api?

The Java Message Service is a Java API that allows applications to create, send, receive, and read messages. Designed by Sun and several partner companies, the JMS API defines a common set of interfaces and associated semantics that allow programs written in the Java programming language to communicate with other messaging implementations.
The JMS API minimizes the set of concepts a programmer must learn to use messaging products but provides enough features to support sophisticated messaging applications. It also strives to maximize the portability of JMS applications across JMS providers in the same messaging domain.
The JMS API enables communication that is not only loosely coupled but also
Asynchronous. A JMS provider can deliver messages to a client as they arrive; a client does not have to request messages in order to receive them.
Reliable. The JMS API can ensure that a message is delivered once and only once. Lower levels of reliability are available for applications that can afford to miss messages or to receive duplicate messages.
The JMS Specification was first published in August 199@The latest version of the JMS Specification is Version 1.1, which was released in April 20@You can download a copy of the Specification from the JMS Web site, http://java.sun.com/products/jms/.

Q14. What Is The Important Part Of Jms Applications?

•Session
•Connection
•Message
•Message Producer
•Message Consumer
•Connection factory and destination

Q15. What Do You Mean By Synchronous And Asynchronous Type Of Messaging?

Synchronous: In this type of messaging, client waits for the server to respond to a message. Ex: Telephone call, two way radio communication.
Asynchronous: In this type of messaging, client does not wait for a message from the server, but automatically an event is created to trigger a message from a server. Ex: email, text messaging, blog posting.

Q16. What Is Asynchronous Messaging? Queue

Asynchronous messaging involves a client that does not wait for a message from the server. An event is used to trigger a message from a server. So even if the client is down , the messaging will complete successfully. 

 

Q17. What Are The Components Of Jms?

•JMS provider
•JMS client
•Messages
•Administered objects
•Native clients

Q18. Mention The Difference Between Durable And Non-durable Subscription?

Durable subscription gives a subscriber the freedom of receiving all messages from a topic, while a non-durable subscription does not make any guarantees about messages sent by others when a client get disconnected by others.

Q19. What Are The Different Parts Of A Jms Message?

A JMS message contains three parts. a header, an optional properties and an optional body. 

Q20. Mention Different Types Of Messages Available In Jms Api?

The different types of messages available in JMS API are Message, TextMessage, BytesMessage, ObjectMessage and MapMessage.

Q21. What Is The Role Of The Jms Provider?

The JMS provider handles data conversion, security of the messages and the client triggering.  It specifies the level of encryption, security level of the message and the best-data type for the non-JMS client.

Q22. Explain How Does The Jms Work With The J2ee?

The application client like enterprise JavaBe components and web components can send or receive JMS message synchronously. In addition, the application clients can also receive message asynchronously.   With the help of message-driven be, JMS provider can optionally implement the processing of messages. Message-driven be are a type of enterprise bean that enables the asynchronous consumption of messages.
The operation of sending and receiving message is carried out in distributed operation, which allows JMS operations and database accesses within a single traction.

Q23. What Is Mom In Reference To Jms?

The MOM ( Message Oriented Middleware) is a software that works as an intermediate between two communicating components.  It is placed between the client and server, MOM provides the facility of passing message by using the technique queuing. Until the client does not request to read the message, the messages will be stored in queue.  By using this technique, the software component can work independently of time.

Q24. What Is The Point-to-point Model In Jms?

A point-to-point model is based on the concept of a message queue: Senders send messages into the queue, and the receiver reads messages from this queue. In the point-to-point model, several receivers can exist, attached to the same queue. However, (Message Oriented Middleware)MOM will deliver the message only to one of them. To which depends on the MOM implementation. 

Q25. What Type Of Messaging Is Provided By Jms?

JMS provides both type of messaging,

  • synchronous
  • Asynchronous

Q26. What Is Jms Session?

A JMS session is a single-threaded context for sending and receiving JMS messages.  A JMS session could be a locally tracted, non-tracted or distributed tracted.

Q27. 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 platform.

Q28. For Sending Messages Through Jms, What Encryption Options Are There?

The encryption and decryption of the messages is handled by JMS provider and not JMS specifications. Sonic MQ by Progress Software is a leading JMS provider and they do encryption through encryption mechanisms called Quality of Protection.

 

Q29. What Is The Difference Between Jms And Rpc (remote Procedure Call)?

The basic difference between JMS and RPC lies in the way they message. JMS uses asynchronous messaging type while, RPC creates synchronous messaging type. The method invoker in RPC, waits for the method to finish execution and return back the control to the invoker. In JMS the message sender just sends the message to the destination and continues its own processing.

Q30. How Many Types Of Messaging Model Do Jms Provide For And What Are They?

There are two types of messaging models that JMS provides –

  • Point to point queuing
  • Second one is public and subscribe

Q31. What Is The Main Parts Of Jms Applications?

The main parts of JMS applications are:

  • ConnectionFactory and Destination
  • Connection
  • Session
  • MessageProducer
  • MessageConsumer
  • Message 

Q32. Explain How Application Server Handles The Jms Connection?

•With the help of Application server, the server session is created and it stores them in a pool
•To put messages in JMS session, connection consumer, uses the Server session
•Server session is the one that creates the JMS session
•Application written by Application programmers creates the message listener.

Q33. What Is Byte Message?

Byte message is a stream of uninterrupted bytes. It contains an array of primitive bytes in its payload.  For the trfer of data between two applications in their native format, byte message is used, which may be not possible with other message types.

Q34. What Is Jms Application?

One or more JMS clients that exchange messages. 

Q35. What Is Synchronous Messaging? Queue

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 fail. 

Q36. Can We Send E-mail Messages Using Jms?

JMS has no inherent support for email operations.

Q37. How You Can Deliver A Java Message To A Non-java Client?

First of all, after receiving the message from Topic or Queue, the message has to be converted into a non-java client according to their specification. The message once converted to non-java client, it can be delivered.

Q38. How May Messaging Models Do Jms Provide For And What Are They?

JMS provides for two messaging models, publish-and-subscribe and point-to-point queuing. 

Q39. What Are The Types Of Messages That Are Supported By Jms?

The types of messages that are supported by JMS are
•Stream Messages
•Text Messages
•Map Messages
•Bytes Messages
•Object Messages

Q40. What Is The Difference Between The P2p (peer To Peer) Model And Subscribe Model?

P2P model is highly reliable and it is used in a one-to-one situation, while subscribe model is used in one-to-many situation. It is very fast but less reliable.