44. What is MOM (Message-Oriented Middleware)?
MOM is a software infrastructure that asynchronously connects multiple systems through the production and consumption of data message.
45. How many types of data passing does JMS specification allows? What are they?
JMS specification allows two types of data passing.
a) publish/subscribe [pub/sub model]
b) point-to-point [P-2-P model]
46. In real time which type of data passing is used?
Mostly in real time applications we use both types of data passing combinedly.
47. How JNDI is used in JMS?
While writing JMS application (pub/sub or p-2-p) we need TopicConnection or QueueConnection. We use JNDI to get these connections.
48. Write the steps to write pub/sub model application?
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 .
49. What is the difference between Durable Subscription and non-Durable Subscription?
Durable Subscription: - indicates that the client wants to receive all the messages published to a topic, including messages published when the client connection is not active.
Non-Durable Subscription: - will not receive the messages published when the client connection is not active.
50. Write the steps to write point-to-point model application?
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.
MOM is a software infrastructure that asynchronously connects multiple systems through the production and consumption of data message.
45. How many types of data passing does JMS specification allows? What are they?
JMS specification allows two types of data passing.
a) publish/subscribe [pub/sub model]
b) point-to-point [P-2-P model]
46. In real time which type of data passing is used?
Mostly in real time applications we use both types of data passing combinedly.
47. How JNDI is used in JMS?
While writing JMS application (pub/sub or p-2-p) we need TopicConnection or QueueConnection. We use JNDI to get these connections.
48. Write the steps to write pub/sub model application?
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 .
49. What is the difference between Durable Subscription and non-Durable Subscription?
Durable Subscription: - indicates that the client wants to receive all the messages published to a topic, including messages published when the client connection is not active.
Non-Durable Subscription: - will not receive the messages published when the client connection is not active.
50. Write the steps to write point-to-point model application?
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.