adplus-dvertising

Welcome to the Messaging and Spring Batch MCQs Page

Dive deep into the fascinating world of Messaging and Spring Batch with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Messaging and Spring Batch, a crucial aspect of Java Spring Framework. In this section, you will encounter a diverse range of MCQs that cover various aspects of Messaging and Spring Batch, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Spring Framework.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Messaging and Spring Batch. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Spring Framework.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Messaging and Spring Batch. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Messaging and Spring Batch MCQs | Page 4 of 16

Q31.
Before you can send and receive JMS messages, you need to install a JMS message broker:-
Discuss
Answer: (d).Apache ActiveMQ
Q32.
In the preceding sendMail() method, you first create JMS-specific ConnectionFactory.
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
public class FrontDeskImpl implements FrontDesk {
 public void sendMail(Mail mail) {
  ConnectionFactory cf =
  new ActiveMQConnectionFactory("tcp://localhost:61616");
  Destination destination = new ActiveMQQueue("mail.queue");
  Connection conn = null;
  try {
   conn = cf.createConnection();
   Session session =
   conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(destination);
   MapMessage message = session.createMapMessage();
   message.setString("mailId", mail.getMailId());
   message.setString("country", mail.getCountry());
   message.setDouble("weight", mail.getWeight());
   producer.send(message);
   session.close();
   } catch (JMSException e) {
    throw new RuntimeException(e);
   } finally {
    if (conn != null) {
    try {
    conn.close();
    } catch (JMSException e) {
    }
   }
  }
 }
}
Discuss
Answer: (a).True
Q33.
In JMS, there are two types of destinations:-
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
public class FrontDeskImpl implements FrontDesk {
	public void sendMail(Mail mail) {
		ConnectionFactory cf =
		new ActiveMQConnectionFactory("tcp://localhost:61616");
		Destination destination = new ActiveMQQueue("mail.queue");
		Connection conn = null;
		try {
			conn = cf.createConnection();
			Session session =
			conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
			MessageProducer producer = session.createProducer(destination);
			MapMessage message = session.createMapMessage();
			message.setString("mailId", mail.getMailId());
			message.setString("country", mail.getCountry());
			message.setDouble("weight", mail.getWeight());
			producer.send(message);
			session.close();
			} catch (JMSException e) {
				throw new RuntimeException(e);
			} finally {
				if (conn != null) {
				try {
				conn.close();
				} catch (JMSException e) {
				}
			}
		}
	}
}
Discuss
Answer: (c).all of the mentioned
Q34.
There are several types of messages defined in the JMS API, including:-
Discuss
Answer: (d).All of the mentioned
Q35.
To send a JMS message with this template, you simply call:-
Discuss
Answer: (a).send
Q36.
The MessageCreator interface declares method:-
Discuss
Answer: (a).createMessage()
Q37.
A JMS template helps you to obtain and release the JMS connection and session.
Discuss
Answer: (a).True
Q38.
JMS sender and receiver classes can also extend to retrieve a JMS template:-
Discuss
Answer: (a).JmsGatewaySupport
Q39.
When you need access to the JMS template.
Discuss
Answer: (b).getJmsTemplate
Q40.
Spring provides an implementation of SimpleMessageConvertor to handle the translation of a JMS message received.
Discuss
Answer: (a).True
Page 4 of 16

Suggested Topics

Are you eager to expand your knowledge beyond Java Spring Framework? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!