Q) What is JMS?
A) Java Message Service: An interface implemented by most J2EE containers to provide point-to-point queueing and topic (publish/subscribe) behavior. JMS is frequently used by EJB's that need to start another process asynchronously. It allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.
For example, instead of sending an email directly from an Enterprise JavaBean, the bean may choose to put the message onto a JMS queue to be handled by a Message-Driven Bean (another type of EJB) or another system in the enterprise. This technique allows the EJB to return to handling requests immediately instead of waiting for a potentially lengthy process to complete.
Q) What type messaging is provided by JMS?
A) Both synchronous and asynchronous are provided by JMS.
Q) How may messaging models do JMS provide for and what are they?
A) JMS provides for two messaging models, publish-and-subscribe and point-to-point queuing
Q) What are the types of messaging?
A) 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.
Q) What is publish/subscribe messaging?
A) 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.
Q) Why doesn't the JMS API provide end-to-end synchronous message delivery and notification of delivery?
A) 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.
Q) What are the core JMS-related objects required for each JMS-enabled application?
A) Each JMS-enabled client must establish the following:
o A connection object provided by the JMS server (the message broker)
o Within a connection, one or more sessions, which provide a context for message sending and receiving
o Within a session, either a queue or topic object representing the destination (the message staging area) within the message broker
o 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)
Q) What is the Role of the JMS Provider?
A) 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.
Q) How does a typical client perform the communication?
A) 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.
Q) Give an example of using the point-to-point model.
A) 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.
Q) Does Tomcat support JMS (Java Messaging Service)?
A) Tomcat is just a servlet container, not an EJB container nor an application server, so it does not contains any JMS basic support.
However, there's nothing stopping you from using another JMS provider
Q) Is it possible to send email messages using JMS?
A) JMS has no inherent support for email operations.
Q) How do I communicate between two clients that are on different machines on a network using JMS? I want to use a standalone application for communicating between the machine and I want to pass the message using JMS.?
A) You can make two JMS client applications, say AppA and AppB. Make AppA listen to topic 'forA'. Make AppB listen to topic 'forB'.
If AppA sends a message to topic 'forB', AppB will receive it. If AppB sends a message to topic 'forA', AppA will receive it.
For sample code etc, try downloading SonicMQ (as a JMS server) and go through the samples.
Q) Is there any relationship between javax.jms.Message and javax.mail.Message?
A) There is no direct relationship between javax.mail.Message and javax.jms.Message. If your requirement is to map (correlate) them, here is what you can do:
1. From JMS domain to JavaMail domain (a javax.jms.Message is received):
1. A JMS topic/queue can be associated with one or many e-mail id(s).
2. The JMS Message Header can be mapped to 'custom' JavaMail Message Header.
3. The JMS Message Body can be associated with the JavaMail Message body.
4. A JavaMail client application should be able to process these 'custom' headers and the content of the message body.
2. From JavaMail domain to JMS domain (a javax.mail.Message is received):
1. An e-mail id can be associated with one or more JMS topics/queues.
2. The JavaMail Message Header can be mapped to 'custom' JMS Message Header.
3. The JavaMail Message Body can be associated with the JMS Message body.
4. The JMS client application should be able to process these 'custom' headers and the content of the message body.
In a simple application that I tried, I removed the 'custom' header scenario and just forwarded the contents of the message (text message), which worked without any problems.Try using SonicMQ bridges, which already has something like that.
Q) Is it possible to acknowledge individual messages on a queue without affecting previously received, but as yet unacknowledged, messages?
A) If you acknowledge a message, all previously received messages will also be acknowledged. From the javax.jms.Message Javadoc, the acknowledge method will "Acknowledge this and all previous messages received."
So the answer to your question is no, if what you meant by "affecting" is not-yet acknowledged.
I suggest an alternative. You should look at javax.jms.QueueBrowser to review queued messages. QueueBrowser has getEnumeration, which "Gets an enumeration for browsing the current queue messages in the order they would be received".
Q) What encryption options are there for sending messages through JMS?
A) Encryption is not handled by the JMS specification. It is left to the JMS provider to implement and provide encryption and decryption of messages. These days, Progress Software's SonicMQ is a leading JMS provider and they have a robust encryption mechanism called Quality of Protection. They also provide an SSL-related feature, which also has build in encryption.
Q) How does the Application server handle the JMS Connection?
A) 1. Application server creates the server session and stores them in a pool.
2. Connection consumer uses the server session to put messages in the session of the JMS.
3. Server session is the one that spawns the JMS session.
4. Applications written by Application programmers creates the message listener.
Q) How JMS is different from RPC?
A) 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.
Q) Are you aware of any major JMS products available in the market?
A) 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 thier own implementation of JMS.
Q) What are the different types of messages available in the JMS API?
A) Message, TextMessage, BytesMessage, StreamMessage, ObjectMessage, MapMessage are the different messages available in the JMS API.
Q) What are the different messaging paradigms JMS supports?
A) Publish and Subscribe i.e. pub/suc and Point to Point i.e. p2p.
Q) What is the difference between topic and queue?
A) 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.
Q) What is the role of JMS in enterprise solution development?
A) 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. B2B or Business to Business: - 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.
Q) What is the use of Message object?
A) 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.
Q) What is the basic difference between Publish Subscribe model and P2P model?
A) 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.
Q) What is the use of BytesMessage?
A) BytesMessage contains an array of primitive bytes in it's payload. Thus it can be used for transfer of data between two applications in their native format which may not be compatible with other Message types. It is also useful where JMS is used purely as a transport between two systems and the message payload is opaque to the JMS client. Whenever you store any primitive type, it is converted into it's byte representation and then stored in the payload. There is no boundary line between the different data types stored. Thus you can even read a long as short. This would result in erroneous data and hence it is advisable that the payload be read in the same order and using the same type in which it was created by the sender.
Q) What is the use of StreamMessage?
A) 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.
Q) What is the use of TextMessage?
A) 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.
Q) What is the use of MapMessage?
A) 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.
Q) What are the advantages of JMS?
A) You can use it in the context of mutithreading but it means JMS is not meant for Multithreading. Its basically meant for object communication.
It will be useful when you are writing some event based applications like Chat Server which needs a publish kind of event mechanism to send messages between the server to the clients who got connected with the server.
Moreover JMS gives Loosely-coupled kind of mechanism when compared with RMI which is tightly-coupled. In JMS there is no need for the destination object to be available online while sending a message from the client to the server. But in RMI it is necessary. So we can use JMS in place of RMI where we need to have loosely-coupled mechanism.
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.
Q) What is the use of ObjectMessage?
A) ObjectMessage contains a Serializable java object as it's payload. Thus it allows exchange of Java objects between applications. This in itself mandates that both the applications be Java applications. The consumer of the message must typecast the object received to it's appropriate type. Thus the consumer should before hand know the actual type of the object sent by the sender. Wrong type casting would result in ClassCastException. Moreover the class definition of the object set in the payload should be available on both the machine, the sender as well as the consumer. If the class definition is not available in the consumer machine, an attempt to type cast would result in ClassNotFoundException. Some of the MOMs might support dynamic loading of the desired class over the network, but the JMS specification does not mandate this behavior and would be a value added service if provided by your vendor. And relying on any such vendor specific functionality would hamper the portability of your application. Most of the time the class need to be put in the classpath of both, the sender and the consumer, manually by the developer.
Q) What is point-to-point messaging?
A) With point-to-point message passing the sending application/client establishes a named message queue in the JMS broker/server and sends messages to this queue. The receiving client registers with the broker to receive messages posted to this queue. There is a one-to-one relationship between the sending and receiving clients.
Q) What is the difference between BytesMessage and StreamMessage?
A) BytesMessage stores the primitive data types by converting them to their byte representation. Thus the message is one contiguous stream of bytes. While the 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. 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.
Q) Can two different JMS services talk to each other? For instance, if A and B are two different JMS providers, can Provider A send messages directly to Provider B? If not, then can a subscriber to Provider A act as a publisher to Provider B?
A) The answers are no to the first question and yes to the second. The JMS specification does not require that one JMS provider be able to send messages directly to another provider. However, the specification does require that a JMS client must be able to accept a message created by a different JMS provider, so a message received by a subscriber to Provider A can then be published to Provider B. One caveat is that the publisher to Provider B is not required to handle a JMSReplyTo header that refers to a destination that is specific to Provider A.
Q) What is the advantage of persistent message delivery compared to nonpersistent delivery?
A) If the JMS server experiences a failure, for example, a power outage, any message that it is holding in primary storage potentially could be lost. With persistent storage, the JMS server logs every message to secondary storage. (The logging occurs on the front end, that is, as part of handling the send operation from the message producing client.) The logged message is removed from secondary storage only after it has been successfully delivered to all consuming clients .
Q) Give an example of using the publish/subscribe model.
A) JMS can be used to broadcast shutdown messages to clients connected to the Weblogic server on a module wise basis. If an application has six modules, each module behaves like a subscriber to a named topic on the server.
Q) How is a java object message delivered to a non-java Client?
A) It is according to the specification that the message sent should be received in the same format. A non-java client cannot receive a message in the form of java object. The provider in between handles the conversion of the data type and the message is transferred to the other end.
Q) What is MDB and What is the special feature of that?
A) 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.
Q) What are the various message types supported by JMS?
A) Stream Messages -- Group of Java Primitives
Map Messages -- Name Value Pairs. Name being a string & Value being a java primitive
Text Messages -- String messages (since being widely used a separate messaging Type has been supported)
Object Messages -- Group of serialize able java object
Bytes Message -- Stream of uninterrupted bytes
Q) What is the difference between JAVA Mail and JMS Queue
A) 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 - is asynchronous point-to-point communication between systems
Q) What is the difference between ic and queue?
A) A ic 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.
Q) What are the three components of a Message ?
A) A JMS message consists of three parts:
Message header
For message identification. For example, the header is used to determine if a given message is appropriate for a "subscriber"
Properties
For application-specific, provider-specific, and optional header fields
Body
Holds the content of the message. Several formats are supported, including TextMessage, which wrap a simple String, that wrap arbitrary Java objects (which must be serializable). Other formats are supported as well.
Q) What kind of information found in the header of a Message ?
A) The header of a message contains message identification and routing information. This includes , but is not limited to :
JMSDestination
JMSDeliveryMode
JMSMessageID
JMSTimeStamp
JMSExpiration
JMSReplyTO
JMSCorrelationID
JMSType
JMSRedelivered
Q) What Is Messaging?
A) 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.
Q) What is the difference between the Mailing and Messaging?
A) Java Mailing is the set of APIs that primarily concerns with the sending of Mail messages through the standard mail protocols. Messaging is the way of communicating to the remote machines using Message Oriented Middlewares. Message Oriented Middlewares do not use mailing internally for communication. They create their own channels for communication
Q) What is synchronous messaging?
A) 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.
Q) What is asynchronous messaging?
A) 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.
Q) What is the difference between queue and topic ?
A) A topic is typically used for one to many messaging , while queue is used for one-to-one messaging. Topic .e. it supports publish subscribe model of messaging where queue supports Point to Point Messaging.
Q) What is Map message?
A) map message contains name value Pairs. The values can be of type primitives and its wrappers. The name is a string.
Q) What is text message?
A) Text messages contains String messages (since being widely used, a separate messaging Type has been supported) . It is useful for exchanging textual data and complex character data like XML.
Q) What is object message ?
A) Object message contains a group of serializeable java object. So it allows exchange of Java objects between applications. sot both the applications must be Java applications.
Q) What is Byte Message ?
A) Byte Messages contains a Stream of uninterrupted bytes. Byte Message contains an array of primitive bytes in it's payload. Thus it can be used for transfer of data between two applications in their native format which may not be compatible with other Message types. It is also useful where JMS is used purely as a transport between two systems and the message payload is opaque to the JMS client.
Q) What is the difference between Byte Message and Stream Message?
A) Bytes Message stores data in bytes. Thus the message is one contiguous stream of bytes. While the Stream Message 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. Bytes Message 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 Stream Message. It maintains the type information of the data being stored and enforces strict conversion rules on the data being read.
Q) What are the different parts of a JMS message ?
A) A JMS message contains three parts. a header, an optional properties and an optional body.
Q) How does JSP handle run-time exceptions?
A) You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. For example:
App server creates the server session and stores them in a pool - Connection consumer uses the server session to put messages in the session of the JMS. - Server session is the one that spawns the JMS session. - Applications written by Application programmers creates the message listener
Q) How EJB Invocation happens?
A) Retrieve Home Object reference from Naming Service via JNDI. Return Home Object reference to the client. Create me a new EJB Object through Home Object interface. Create EJB Object from the Ejb Object. Return EJB Object reference to the client. Invoke business method using EJB Object reference. Delegate request to Bean (Enterprise Bean).
Q) Must I place all my class files in the WEB-INF folder and all JSP's outside?
A) The class files should place into WEB-INF/classes folder and the JSP files should place within a separate folder.
Q) What is the point-to-point model in JMS?
A) 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.
Q) What is the difference between Point to Point and Publish/Subscribe Messaging Domains
A) A point-to-point (PTP) product or application is built around the concept of message queues, senders, and receivers. Each message is addressed to a specific queue, and receiving clients extract messages from the queue(s) established to hold their messages. Queues retain all messages sent to them until the messages are consumed or until the messages expire
In a publish/subscribe (pub/sub) product or application, clients address messages to a topic. Publishers and subscribers are generally anonymous and may dynamically publish or subscribe to the content hierarchy. The system takes care of distributing the messages arriving from a topic's multiple publishers to its multiple subscribers. Topics retain messages only as long as it takes to distribute them to current subscribers.
Q) What is Stream Message ?
A) Stream messages are a group of java primitives. It contains some convenient methods for reading the data. However Stream Message prevents reading a long value as short. This is so because the Stream Message also writes the type information along with the value of the primitive type and enforces a set of strict conversion rules which actually prevents reading of one primitive type as another.
Q) 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.
Q) What is JMS administered object?
A) preconfigured JMS object (a resource manager connection factory or a destination) created by an administrator for the use of JMS clients and placed in a JNDI namespace
Q) Which models are supported by JMS? Please, explain them.
A) 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.
Q) What is the main parts of JMS applications?
A) The main parts of JMS applications are:
--ConnectionFactory and Destination
--Connection
--Session
--MessageProducer
--MessageConsumer
--Message
Q) Does JMS specification define transactions? Queue
A) JMS specification defines a transaction mechanisms allowing clients to send and receive groups of logically bounded messages as a single unit of information. A Session may be marked as transacted. It means that all messages sent in a session are considered as parts of a transaction. A set of messages can be committed (commit() method) or rolled back (rollback() method). If a provider supports distributed transactions, it's recommended to use XAResource API.
Q) What is JMS session?
A) A single-threaded context for sending and receiving JMS messages. A JMS session can be nontransacted, locally transacted, or participating in a distributed transaction.
Q) What is the use of JMS? In which situations we are using JMS? Can we send message from one server to another server using JMS?
A) JMS is the ideal high-performance messaging platform for intrabusiness messaging, with full programmatic control over quality of service and delivery options.
Q) What is the difference between durable and non-durable subscriptions?
A) Point-To-Point (PTP). This model allows exchanging messages via queues created for some purposes. A client can send and receive messages from one or several queues. PTP model is easier than pub/sub model.
A durable subscription gives a subscriber the freedom of receiving all messages from a topic, whereas a non-durable subscription doesn't make any guarantees about messages sent by others when a client was disconnected from a topic.
Q) What is the difference between Message producer and Message consumer?
A) Messaging systems provide a host of powerful advantages over other conventional distributed computing models. Primarily, they encourage "loose coupling" between message consumers and message producers. There is a high degree of anonymity between producer and consumer: to the message consumer, it doesn't matter who produced the message, where the producer lives on the network, or when the message was produced.
Q) What is JMS application ?
A) One or more JMS clients that exchange messages.
Q) What is the root exception of JMS?
A) JMSException is the root class for exceptions thrown by JMS API methods.
Q) What are message properties?
A) Message properties are additional user defined properties other than those that are defined in the header.
Q) What is a message header?
A) A JMS message header contains a number of predefined fields that contain values that both clients and providers use to identify and to route messages.Each header field has associated setter and getter methods, which are documented in the description of the Message interface.
Q) What Is the JMS API?
A) 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 1998. The latest version of the JMS Specification is Version 1.1, which was released in April 2002. You can download a copy of the Specification from the JMS Web site, http://java.sun.com/products/jms/.
Q) What are the different elements present in JMS?
A) The different elements present in JMS are: -
* JMS provider, client, producer, consumer, message, topic and queue. Java client helps in processing and sending messages, this is the primary requisite for JMS to function.
Q) Explain about JMS queue?
A) This acts as a queue where messages are removed once sent to the receiver. This acts as a storage area where messages or products are sent and ready to be accepted by the user. In this queue messages are sent in an orderly fashion and order.
Q) What are the two parts of a message and explain them?
A) A message basically has two parts : a header and payload. The header is comprised of special fields that are used to identify the message, declare attributes of the message, and provide information for routing. Payload is the type of application data the message contains.
Q) How many types of messages are there and What are they?
A) There are 5 types of Messages. They are:
a. TextMessage : A java.lang.String object (for example, the contents of an Extensible Markup Language file).
b. MapMessage : A set of name/value pairs, with names as String objects and values as primitive types in the Java programming language. The entries can be accessed sequentially by enumerator or randomly by name. The order of the entries is undefined.
c. BytesMessage : A stream of uninterpreted bytes. This message type is for literally encoding a body to match an existing message format.
d. StreamMessage: A stream of primitive values in the Java programming language, filled and read sequentially.
e. ObjectMessage: A Serializable object in the Java programming language.
Q) What is a Message?
A) A message is a package of business data that is sent from one application to another over the network. The message should be self-describing in that it should contain all the necessary context to allow the recipients to carry out their work independently.
Q) Name few subclasses of JMSException.
A) a. MessageFormatException
b. MessageEOFException
c. InvalidClientIDException
d. InvalidDestinationException
e. InvalidSelectorException
Q) What is a message listener?
A) A message listener is an object that acts as an asynchronous event handler for messages. This object implements the MessageListener interface, which contains one method, onMessage. In the onMessage method, you define the actions to be taken when a message arrives.
Q) What is a destination?
A) A destination is the object a client uses to specify the target of messages it produces and the source of messages it consumes. In the PTP messaging domain, destinations are called queues and in the pub/sub messaging domain, destinations are called topics.
Q) What are the parts of a JMS message?
A) A JMS message has three parts:
a. header
b. Properties (optional)
c. body (optional)
Q) Can a message selector select messages on the basis of the content of the message body?
A) No. The message selection is only based on message header and message properties.
Q) What is a message selector?
A) Message selector filters the messages received by the consumer based on a criteria. Message selectors assign the work of filtering messages to the JMS provider rather than to the application. A message selector is a String that contains an expression. The syntax of the expression is based on a subset of the SQL92 conditional expression syntax. The message consumer then receives only messages whose headers and properties match the selector.
Q) Explain about point to point?
A) At the first point a producer posts a message to the receiver where it stays in a particular queue until the receiver opens the message from the queue. In this model predefining of the user is very important and in this form of model only one user will receive the message. During the process of the message it is not imperative for the user and sender to be online. Message opened is acknowledged.
Q) What are the different places where you can use the JMS API?
A) The different places where JMS API can be used are as follows: -
1) Provider of the message need not depend upon the component of the user
2) Application running should not be affected by the components
3) Where component request of acknowledgement of message is not mandatory.
Q) What are all the features of JMS API in J2EE platform?
A) EJB components, web components and application clients can send messages synchronously as well as receive the messages asynchronously from these applications .Messages can participate in distributed transactions .
Asynchronous consumption of messages and implementation of concurrent processing are some of the features and benefits of using JMS in J2EE.
Q) Explain about publish model?
A) This model of messaging is useful when the clients subscribe to a particular service of messaging. Both the client and consumer remain alien. This form of technology is fast gaining ground in commercial usage of messaging. This separates the application from the transport layer.
Q) Detail about the features of publish model?
A) The following are the features of the publish model they are: -
1) Multiple clients or consumers can receive the message simultaneously.
2) Timing dependency is a factor between the client and publisher. Client will not receive messages unless the client remains active all the time. This can be eliminated when a client has durable subscription.
Q) What are the three parts of the message?
A) A message has three parts they are
1) A message header : - Contains operational settings
2) Message properties: -Has settings for compatibility and selectors
3) Optional message body: -Info or message you want to convey.
Q) Explain about Connection interface?
A) This acts as a connection link once the settings are configured between the client and the service provider. It all depends upon the connection type where sessions are configured. Connection to the JMS can be created once the settings are compatible.
Q) Explain about the exception handling mechanism of JMS?
A) JMS Exception mechanism is the root class thrown by JMS API. All the exceptions generated by JMS API are handled by Catching JMS Exception. Some of the sub classes generated by the exception are as follows
1) InvalidclientIDException
2) JMSSecurityException etc.
Q) Is JMS a specification or a product?
A) JMS is a specification.
Q) What are two messaging models or messaging domains?
A) a. Point-to-Point Messaging domain.
b. Publish/Subscribe Messaging domain
Q) What are the features of JMS?
A) The following are the important features of JMS:
a. Asynchronous Processing.
b. Store and forwarding.
c. Guaranteed delivery.
d. Provides location transparency.
e. Service based Architecture.
Q) Explain the creation of JMS Administered objects?
A) A topic should be created in the window in which clients were compiled. Here you can create a topic by the command j2eeadmin and name the topic as MyTopic. Argument specified at the last determines the destination. Verification of the queue should be done. j2eeadmin -listJmsDestination following command verifies whether the queue is created or not.
Q) Explain Pub/Sub Messaging model.
A) In a publish/subscribe (pub/sub) product or application, clients address messages to a topic. Publishers and subscribers are generally anonymous and may dynamically publish or subscribe to the content hierarchy. The system takes care of distributing the messages arriving from a topic's multiple publishers to its multiple subscribers. Topics retain messages only as long as it takes to distribute them to current subscribers.
Pub/sub messaging has the following characteristics:
a. Each message may have multiple consumers.
b. Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.
Q) What is a connection factory?
A) A connection factory is the object a client uses to create a connection with a provider. A connection factory encapsulates a set of connection configuration parameters that has been defined by an administrator.Each connection factory is an instance of either the QueueConnectionFactory or the TopicConnectionFactory interface.
Q) What are the two types of Message Consumption?
A) a.Synchronous Consumption :A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.
b. Asynchronous Consumption : A client can register a message listener with a consumer. A message listener is similar to an event listener. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener's onMessage method, which acts on the contents of the message.
Q) Explain about session interface?
A) Session interface is an important concept which deals partly with the queue system. It is a single thread session where messages are sent in an order. It holds the messages if transaction phase is selected and it also has facility for roll back.
Q) Explain about message selector?
A) Message selector contains an expression and it acts like a string. The syntax is based on the SQL92 conditional expression. Create receiver, create durable subscriber and create subscriber has a form which allows a person to specify message selector as an argument.
Q) Explain about Connection factory interface?
A) This has settings which creates a connection between the client and JMS provider. These settings are accessed through portable interface and need not be changed every time. These settings are configured in JNDI namespace.
Q) Explain about map message?
A) Map message contains name/value pairs. Names are stored as strings and values are stores as primitives in Java programming language. Names can be accessed from the database with the help of enumerator. The way the entries are stored cannot be accessed.
Q) Explain about message listeners?
A) It acts as an asynchronous event handler for messages. It implements the message listener interface. A developer defines the actions which should be taken when the message arrives such as deleting, forwarding, etc. A queue connection can be initiated once this connection is defined.
Q) Explain Point-to-Point Messaging model.
A) A point-to-point (PTP) product or application is built around the concept of message queues, senders, and receivers. Each message is addressed to a specific queue, and receiving clients extract messages from the queue(s) established to hold their messages. Queues retain all messages sent to them until the messages are consumed or until the messages expire.
Point-to-Point Messaging has the following characteristics:
a. Each Message has only one consumer.
b. The receiver can fetch the message whether or not it was running when the client sent the message.
c. The receiver acknowledges the successful processing of a message.