Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Questions and Answers

  1. If there is no ConnectionFactory object created by the JMS provider administrator, what can I do?

  2. A ConnectionFactory object is an administered object and must be created by the JMS provider administrator. If there is no ConnectionFactory object created, you can use the default ConnectionFactory object. You will learn more detailed information in the section, "Basic Steps to Write a JMS Application," in the next chapter.

  3. If there is no Destination object created by the JMS provider administrator, what can I do?

  4. A Destination object is an administered object like the ConnectionFactory object and must be created by the JMS provider administrator. If there is no Destination object created, you cannot use the JMS API for messaging. There is no default Destination object.

  5. If I do not specify a value for the time-to-live method of the Message interface, what will happen to the message if the receiver is inactive?

  6. If you do not specify a time for time-to-live, it means that the message will never expire. The message will be delivered whenever the receiver client is available, depending on the messaging model you are using.

  7. Can I create two or more connections to send messages?

  8. Yes, you can. Some advanced applications might use several connections. But a connection is a relatively heavyweight object. Therefore, only one connection is preferred. If you need to, you can create two or more sessions—which are lightweight JMS objects—and a number of message producers and consumers to send messages on different channels.

  9. If I use transacted messaging and if the connection or session is closed in the middle of transmitting without an acknowledgment, what will happen to the message that is not sent to the destination?

  10. In this case, the JMS provider will call the rollback() method, the messages that are not delivered will be deleted, and the messages already delivered to the destination will be removed from the destination by a JMS provider. The recipient will not receive any messages.

  11. I want to filter some messages that should not be delivered to the consumer. How can I define a field in a message selector for some values in the message body?

  12. A message selector only works with header and property fields. You cannot filter messages based on values in the message body.

  13. In the message received, there is a ReplyTo field. If this destination is not created, how can I send a message to the destination specified in a ReplyTo field?

  14. You can create a temporary destination dynamically. During the session, the connection is open, so you can send the message to this temporary destination. Whenever the connection is closed, this destination is removed along with the messages that have not yet been delivered.

  • + Share This
  • 🔖 Save To Your Account