Jms Questions

JMS Interview Questions :-

  What is JMS?

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.

  What are the 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.

  What type of messaging is provided by JMS?

JMS provides both type of messaging :-

1. Synchronous

2. Asynchronous

  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.

  How many types of messaging model do JMS provide for and what are they?

There are two types of messaging models that JMS provides :-

1. Point to point queuing.

2. Second one is public and subscribe.

  What do you mean by Synchronous and Asynchronous type of messaging?

1. Synchronous :- In this type of messaging, client waits for the server to respond to a message.

Example :- Telephone call, two way radio communication.

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

Example :- email, text messaging, blog posting.

  What are the different types of messages available in the JMS API?

There are many different types of messages available in the JMS API :-

1. Message.

2. TextMessage.

3. BytesMessage.

4. StreamMessage

5. ObjectMessage

6. MapMessage

  Explain the difference between topic and queue?

Queue :- Queue technique is used for one to one messaging, and it supports point to point messaging

Topic :- Topic is typically used for one to many messaging and it supports public subscribe model of messaging.

  Describe briefly the components of the Java Messaging Service.

The JMS application comprises of the following components :-

1. JMS provider :- This is the main messaging system which provides with the JMS interfaces. It also provides with the panel to control administrative and control features.

2. JMS clients :- These comprise the programs and components which are written using the Java programming language. They are responsible for the production and consumption of messages.

3. Messages :- These are the objects that are used to communicate between two clients.

4. Administered objects :- These are predefined objects created by the administrator which can be used by the clients.

5. Native clients :- These are programs that do not use the JSM API client but instead uses its own native API client.

  What is a MOM in reference to JMS?

Software components in a distributed computing network often need to pass messages between them. These are to be done asynchronously.

The MOM or the Message Oriented Middleware is a software that is placed between any two communicating components. A middleware is a component that is placed between the client and the server. The MOM provides the facility of message passing by using the technique of queuing. All the messages are stored in the form of queue till the client that requested it can read it. The basis of reading messages by the client can be by FIFO or priority. By using the concept of queuing the software components can work independently of time.

  What is the use of Message object?

Message is a light weight message having only header and properties and no payload. Thus if the receivers are to be notified about an event, and no data needs to be exchanged then using Message can be very efficient.

  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.

  What is the use of StreamMessage?

StreamMessage carries a stream of Java primitive types as it's payload. It contains some conveient methods for reading the data stored in the payload. However StreamMessage prevents reading a long value as short, something that is allwed in case of BytesMessage. This is so because the StreamMessage also writes the type information alonwgith the value of the primitive type and enforces a set of strict conversion rules which actually prevents reading of one primitive type as another.

  What is the important part of JMS applications?

1. Session.

2. Connection..

3. Message.

4. Message Producer.

5. Message Consumer.

6. Connection factory and destination.

  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.

  Mention the difference between durable and non-durable subscription?

1. Durable :- Durable subscription gives a subscriber the freedom of receiving all messages from a topic,

2. Non-Durable :- A Non-Durable subscription does not make any guarantees about messages sent by others when a client get disconnected by others. Functions that are first class will have some objects whose properties and methods are given by using the methods like length() and call(). These methods can be given different varibles and passed by an argumnent.

  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.

  Can we send e-mail messages using JMS?

JMS has no inherent support for email operations..

  What is the difference between BytesMessage and StreamMessage?

1. BytesMessage :- BytesMessage stores the primitive data types by converting them to their byte representation. Thus the message is one contiguous stream of bytes. BytesMessage allows data to be read using any type. Thus even if your payload contains a long value, you can invoke a method to read a short and it will return you something. It will not give you a semantically correct data but the call will succeed in reading the first two bytes of data. This is strictly prohibited in the StreamMessage. It maintains the type information of the data being stored and enforces strict conversion rules on the data being read.

2. StreamMessage :- StreamMessage maintains a boundary between the different data types stored because it also stores the type information along with the value of the primitive being stored.

  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.

  What is the role of JMS in enterprise solution development?

JMS is typically used in the following scenarios :-

1. Enterprise Application Integration :- Where a legacy application is integrated with a new application via messaging.

2. Business to Business B2B or :- Businesses can interact with each other via messaging because JMS allows organizations to cooperate without tightly coupling their business systems.

3. Geographically dispersed units :- JMS can ensure safe exchange of data amongst the geographically dispersed units of an organization.

4. One to many applications :- The applications that need to push data in packet to huge number of clients in a one-to-many fashion are good candidates for the use JMS. Typical such applications are Auction Sites, Stock Quote Services etc.

  Are you aware of any major JMS products available in the market?

IBM's MQ Series is one of the most popular product used as Message Oriented Middleware. Some of the other products are SonicMQ, iBus etc. All the J2EE compliant application servers come built with their own implementation of JMS.

  For JMS-enabled application, what are the core JMS-related objects required?

The core JMS-related objects that are required are :-

1. The connection object.

2. One or more sessions within a connection that provides a context for message sending and receiving.

3. A topic or queue object within a session representing the destination within the message broker.

4. Appropriate sender or publisher or receiver within a session.

  What are the different ways in which the message delivery can be made more reliable?

The different ways in which the reliability of the message delivery system can be effected are :-

1. Controlling message acknowledgement :- The user can specify different levels of control over acknowledgement.

2. Specifying message persistence :- The user can set the messages to be persistent so that they are not lost in case of failures.

3. Setting priority levels :- The user can set the priority of various messages.

4. Message expiry :- The user can set the expiration time for messages.

5. Temporary destinations :- The user can create temporary destinations which last only till the duration of the connection.

  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.

  What is the difference between JAVA Mail and JMS Queue?

Java Mail :- Java Mail – API siting on top of e-mail protocols like SMTP, POP, IMAP –essentially same stuff e-mail clients like MS outlook use .. hence make sense if at least on one side of conversation we have human.

JMS Queue :- JMS Queue –is asynchronous point-to-point communication between systems.

  What is Decentralized MOM and Centralized MOM?

Centralized MOM :- Centralized MOM means centralized messaging. JMS uses centralized messaging, where every application/client talks to a centralized messaging broker, even for (point-to-point)p2p communication.

DCentralized MOM :- Decentralized MOM, the clients communicate to each other directly.

  What is JVT?

JVT is used for synchronous process. It uses Java Objects for communications. Java Objects are sent across the networks. Its not related to JMS.

  What is MDB and What is the special feature of that?

MDB is Message driven bean, which very much resembles the Stateless session bean. The incoming and out going messages can be handled by the Message driven bean

The ability to communicate asynchronously is the special feature about the Message driven bean.

  What is MDB and What is the special feature of that?

MDB is Message driven bean, which very much resembles the Stateless session bean. The incoming and out going messages can be handled by the Message driven bean

The ability to communicate asynchronously is the special feature about the Message driven bean.


Let's do interview preparation for node.js..

Read more