Top 25 JMS (Java Message Service) Interview Questions & Answers

1) What is JMS?

JMS means 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.

2) What type of messaging is provided by JMS?

JMS provides both type of messaging,

  • synchronous
  • Asynchronous

3) 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.

4) 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

5) Explain the difference between topic and queue?

Queue technique is used for one to one messaging, and it supports point to point messaging. While topic is typically used for one to many messaging and it supports public subscribe model of messaging.

Java Message Service

Java Message Service

6) 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.

7) What are the components of JMS?

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

8) 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.

9) 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.

10) 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.

11) What is the important part of JMS applications?

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

12) 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 transacted, non-transacted or distributed transacted.

13) 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.


14)  What is Byte Message?

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

15)  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.

16) 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.

17) What is a JMS client?

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

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.


FacebookTwitter
blog comments powered by Disqus