Latest 50 JMS Interview Questions
1. What is JMS (Java Messaging Service)?
JMS is an acronym used for Java Messaging Service. It is Java’s answer to creating software using asynchronous messaging. It is one of the official specifications of the J2EE technologies and is a key technology.
2. How the 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.
3. What are the basic advantages of JMS?
JMS is asynchronous in nature. Thus not all the pieces need to be up all the time for the application to function as a whole. Even if the receiver is down the MOM will store the messages on it’s behalf and will send them once it comes back up.
Thus at least a part of application can still function as there is no blocking.
4. What are the different types of messages available in the JMS API?
Message, TextMessage, BytesMessage, StreamMessage, ObjectMessage, MapMessage are the different messages available in the JMS API.
5. What are the different messaging paradigms JMS supports?
Publish and Subscribe i.e. pub/suc and Point to Point i.e. p2p.
6. What is the difference between topic and queue?
A topic is typically used for one to many messaging i.e. it supports publish subscribe model of messaging. While queue is used for one-to-one messaging i.e. it supports Point to Point Messaging.
7. What is the use of Message object?
Message is a light weight message having only header and properties and no payload. Thus if theIf the receivers are to be notified abt an event, and no data needs to be exchanged then using Message can be very efficient.
8. What is the basic difference between Publish Subscribe model and P2P model?
Publish Subscribe model is typically used in one-to-many situation. It is unreliable but very fast. P2P model is used in one-to-one situation. It is highly reliable.
9. What is the use of TextMessage?
TextMessage contains instance of java.lang.String as it’s payload. Thus it is very useful for exchanging textual data. It can also be used for exchanging complex character data such as an XML document.
10. What is the use of MapMessage?
A MapMessage carries name-value pair as it’s payload. Thus it’s payload is similar to the java.util.Properties object of Java. The values can be Java primitives or their wrappers
11. What is JMS provider?
An implementation of the JMS interface for a Message Oriented Middleware (MOM). Providers are implemented as either a Java JMS implementation or an adapter to a non-Java MOM.
12. Wat is JMS client?
An application or process that produces and/or receives messages.
13. What is JMS producer?
A JMS client that creates and sends messages.
14. What is JMS consumer?
A JMS client that receives messages.
15. What is JMS message?
An object that contains the data being transferred between JMS clients.
16. What is JMS queue?
A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don’t have to be delivered in the order sent. If the message driven bean pool contains more than one instance then messages can be processed concurrently and thus it is possible that a later message is processed sooner than an earlier one.
A JMS queue guarantees only that each message is processed only once.
17. What is JMS topic?
A distribution mechanism for publishing messages that are delivered to multiple subscribers.
18) Can we send e-mail messages using JMS?
JMS has no inherent support for email operations.
19) 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.
20) 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.
21) Explain how does the JMS work with the J2EE?
The application client like enterprise JavaBeans 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 beans, JMS provider can optionally implement the processing of messages. Message-driven beans 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 transaction.
22) 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
23) 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.
24) 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.
25) 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.
26. What is JMS queue?
A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages don’t have to be delivered in the order sent.
If the message driven bean pool contains more than one instance then messages can be processed concurrently and thus it is possible that a later message is processed sooner than an earlier one. A JMS queue guarantees only that each message is processed only once.
27. Wat is JMS client?
An application or process that produces and/or receives messages.
28. What is JMS producer?
A JMS client that creates and sends messages.
29. What is JMS consumer?
A JMS client that receives messages.
30. What is JMS message?
An object that contains the data being transferred between JMS clients.