1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

JMS interview questions

!!! JMS interview questions !!!

What are the steps to send and receive JMS message ?

Step 1.
lookup the ConnectionFactory .
(A connection factory is the object a client uses to create a connection to 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 the ConnectionFactory, QueueConnectionFactory, or TopicConnectionFactory interface)

Context ctx = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory)

Step 2.
lookup the destination (A destination is the object a client uses to specify the target of messages it produces and the source of messages it consumes.)

Destination myDest = (Destination) ctx.lookup("jms/MyTopic");
Queue myQueue = (Queue) ctx.lookup("jms/MyQueue");

Step 3.
Create the Connection
Connection connection = connectionFactory.createConnection();

Step 4.
Session session = connection.createSession(false,

The first argument means that the session is not transacted; the second means that the session automatically acknowledges messages when they have been received successfully

Step 5.
Create Message Producers

You use a Session to create a MessageProducer for a destination. Here, the first example creates a producer for the destination myQueue, and the second for the destination myTopic:

MessageProducer producer = session.createProducer(myQueue);
MessageProducer producer = session.createProducer(myTopic);

Step 6.
Create message and send message

TextMessage message = session.createTextMessage();

Step 7.
create Message Consumers and receive message
MessageConsumer consumer = session.createConsumer(myQueue);
MessageConsumer consumer = session.createConsumer(myTopic);

Message m = consumer.receive();
if (m instanceof TextMessage) {
TextMessage message = (TextMessage) m;
System.out.println("Reading message: " + message.getText());
} else {
// Handle error

Reviews and Comments

PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2019

About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy