Skip to main content

JMS (JAVA MESSAGING SERVICE)

1. What is JMS ?
A. JMS (JAVA MESSAGING SERVICE) is an API .It is a specification with one
package javax.jms .It is a technology which can pass the information
synchronously or asynchronously .

2. On what technology is JMS based ?
A. JMS is based on Message-Oriented MiddleWare (MOM).

3. What was the technology for messaging services before JMS was released?
A. Before JMS API specification was released by javasoft ,there was
IBM’s MQSeries implementation of MOM (Message-Oriented MiddleWare).

4. What is MOM (Message-Oriented MiddleWare) ?
A. MOM is a software infrastructure that asynchronously connects multiple
system’s through the production and consumption of data message.

5. How many types of data passing does JMS specification allows ?What are they?
A. JMS specification allows two types of data passing.
a)publish/subscribe [pub/sub model]
b)point-to-point [p-t-p model]

6. In real time which type of data passing is used ?
A. Mostly in real time applications we use both types of data passing combinedly.

7. How jndi is used in JMS ?
A. While writing JMS application (pub/sub or p-t-p) we need TopicConnection or
QueueConnection . we use jndi to get this connections .


8. Write the steps to write pub/sub model application ?
A.
steps to write Publisher (sender) application :-
a)We have to get the TopicConnection through jndi.
b)Create TopicSession by invoking a method createTopicSession() .
c)create a Topic object by invoking createTopic() on TopicSession interface.
d)create a TopicPublisher object of a Topic by invoking createPublisher(javax.jms.Topic t)
on TopicSession.(t is a Topic object that specifies the Topic we want to subscribe to).
e)create TextMessage object and set the text to be published .
f)publish the message by using a method publish() in Publisher interface .
steps to write subscriber (receiver) application :-
a)We have to get the TopicConnection through jndi.
b)Create TopicSession by invoking a method createTopicSession() .
c)create a Topic object by invoking createTopic() on TopicSession interface.
d)create a TopicSubscriber object of a Topic by invoking createSubscriber(javax.jms.Topic) or
createDurableSubscriber(javax.jms.Topic t,String name,String messageselector,boolean nolocal) on TopicSession.
t ------> is a Topic object that specifies the Topic we want to subscribe to.
name ---> is a String that indicates the name under which to maintain the Durable Subscribtion to the specified topic.
messageselector --> is a String that defines selection criteria.
nolocal -------> is a boolean if it is true the Subscriber will not recive messages that were published by the client application .

9. What is the diffrence between DurableSubscription and non-DurableSubscription ?
A.
DurableSubscription :-
DurableSubscription indicates that the client wants to recive all the messages published to a topic,
including messages published when the client connection is not active.
Non-DurableSubscription :-
Non-DurableSubscription will not recive the messages published when the client connection is not active.

10. Write the steps to write p-to-p model application ?
A.
steps to write Sender application :-
a)We have to get the QueueConnection through jndi.
b)Create QueueSession by invoking a method createQueueSession() .
c)Create a Queue object by invoking createQueue() on QueueSession interface.
d)Create a QueueSender object of a Queue by invoking createSender(javax.jms.Queue q)
on QueueSession.
e)Create TextMessage object and set the text to be send .
f)Send the message by using a method send() .
steps to write Receiver application :-
a)We have to get the QueueConnection through jndi.
b)Create QueueSession by invoking a method createQueueSession() .
c)Create a Queue object by invoking createQueue() on QueueSession interface.
d)Create a QueueReceiver object of a Queue by invoking createReceiver(javax.jms.Queue) on QueueSession.

Comments

Popular posts from this blog

Asynchronous Vs. Synchronous Communications

Synchronous (One thread):   1 thread -> |<---A---->||<----B---------->||<------C----->| Synchronous (multi-threaded):   thread A -> |<---A---->| \ thread B ------------> ->|<----B---------->| \ thread C ----------------------------------> ->|<------C----->|

WebSphere MQ Interview Questions

What is MQ and what does it do? Ans. MQ stands for MESSAGE QUEUEING. WebSphere MQ allows application programs to use message queuing to participate in message-driven processing. Application programs can communicate across different platforms by using the appropriate message queuing software products. What is Message driven process? Ans . When messages arrive on a queue, they can automatically start an application using triggering. If necessary, the applications can be stopped when the message (or messages) have been processed. What are advantages of the MQ? Ans. 1. Integration. 2. Asynchrony 3. Assured Delivery 4. Scalability. How does it support the Integration? Ans. Because the MQ is independent of the Operating System you use i.e. it may be Windows, Solaris,AIX.It is independent of the protocol (i.e. TCP/IP, LU6.2, SNA, NetBIOS, UDP).It is not required that both the sender and receiver should be running on the same platform What is Asynchrony? Ans. With messag...

Advantages & Disadvantages of Synchronous / Asynchronous Communications?

  Asynchronous Communication Advantages: Requests need not be targeted to specific server. Service need not be available when request is made. No blocking, so resources could be freed.  Could use connectionless protocol Disadvantages: Response times are unpredictable. Error handling usually more complex.  Usually requires connection-oriented protocol.  Harder to design apps Synchronous Communication Advantages: Easy to program Outcome is known immediately  Error recovery easier (usually)  Better real-time response (usually) Disadvantages: Service must be up and ready. Requestor blocks, held resources are “tied up”.  Usually requires connection-oriented protocol