JMS Interview Questions

February 13, 2009

Interview Questions, JMS

«»

1) What is JMS?

Java Message Service is the new standard for interclient communication. It allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.

2) What type messaging is provided by JMS

Both synchronous and asynchronous

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

4) What are the types of messaging?

There are two kinds of Messaging:

  • Synchronous messaging involves a client that waits for the server to respond to a message.
  • 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.

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

6) Why doesn’t the JMS API provide end-to-end synchronous message delivery and notification of delivery?

Some messaging systems provide synchronous delivery to destinations as a mechanism for implementing reliable applications. Some systems provide clients with various forms of delivery notification so that the clients can detect dropped or ignored messages. This is not the model defined by the JMS API. JMS API messaging provides guaranteed delivery via the once-and-only-once delivery semantics of PERSISTENT messages. In addition, message consumers can insure reliable processing of messages by using either CLIENT_ACKNOWLEDGE mode or transacted sessions. This achieves reliable delivery with minimum synchronization and is the enterprise messaging model most vendors and developers prefer. The JMS API does not define a schema of systems messages (such as delivery notifications). If an application requires acknowledgment of message receipt, it can define an application-level acknowledgment message.

7) What are the core JMS-related objects required for each JMS-enabled application?

Each JMS-enabled client must establish the following:

  • A connection object provided by the JMS server (the message broker)
  • Within a connection, one or more sessions, which provide a context for message sending and receiving
  • Within a session, either a queue or topic object representing the destination (the message staging area) within the message broker
  • Within a session, the appropriate sender or publisher or receiver or subscriber object (depending on whether the client is a message producer or consumer and uses a point-to-point or publish/subscribe strategy, respectively). Within a session, a message object (to send or to receive)

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

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

10) Give an example of using the point-to-point model.

The point-to-point model is used when the information is specific to a single client. For example, a client can send a message for a print out, and the server can send information back to this client after completion of the print job.

email

«»

Comments

comments

,