concept message in category jboss

appears as: messages, message, message, messages, A message, The messages
JBoss in Action: Configuring the JBoss Application Server

This is an excerpt from Manning's book JBoss in Action: Configuring the JBoss Application Server.

If the server log file grows too rapidly, or you want to suppress messages displayed on the console log, you can change the logging options to reduce the amount of logging.

The Store class implements the MessageListener interface so that it can receive asynchronous reservation requests from the customers, freeing the class from having to constantly poll the topic for such requests. The class sends messages on one thread and receives messages on a separate thread, a process which is controlled by the messaging client component. You have to do more work in the class because it uses two threads, as you’ll see later in the code. In addition, you declare an input stream, which is used to get information about the video.

package org.jbia.jms.sofaspuds;
import java.io.*;
import javax.jms.*;
import javax.naming.*;
public class Store implements MessageListener {
private BufferedReader rdr
= new BufferedReader(new InputStreamReader(System.in));

You need only a single connection but require a session for each topic, a producer for one topic, and a consumer for the other. Use two sessions because you publish messages on one thread and receive messages on a separate thread, and each thread requires its own session; you can’t access a single session from multiple threads.

Understanding Messages

You’ve probably noticed that we’ve not yet defined what a message is—an important topic, considering that this chapter is about messaging. Although you probably already know this, a message is some data. What you want to know is: What kind of data can you send in a message? And that’s the question we answer in this section.

Figure 8.5 shows the anatomy of a message, which consists of a header, properties, and a payload that contains the message data.

Figure 8.5. A message consists of three data areas: a header, a set of properties, and the payload.

The header area contains a set of properties, which are required by the JMS specification and consist of values such as a unique message id, JMSMessageId, and the timestamp of when the message was sent, JMSTimestamp. Getters and setters are provided on the javax.jms.Message interface to access these values. We don’t go into detail on the header properties and the data they provide; you can read more about them in the JMS specification.

The properties area can contain several categories of properties, as described in table 8.1. The Message interface provides methods to get and set the properties of a message. In addition, a message receiver or subscriber can define a message selector based on message properties so that it receives only those messages that match a certain criteria—much like using a WHERE clause in an SQL statement to access specific data in a database. Although you can transmit an entire message using only properties and no payload, you should place the message into the payload area and use the properties only for data that you might want to use to select messages.

Table 8.1. Message property categories

Property category

Description

JMS-defined

Optional properties described in the JMS specification. The names of these properties all begin with the string JMSX. Of the optional properties, JBoss Messaging provides only the JMSXDeliveryCount property, which identifies how many times the server attempted to deliver the message.

Vendor-specific

Properties provided by the messaging service vendor. The names of these properties all begin with the string JMS_, followed by the vendor name. JBoss Messaging doesn’t have any vendor-specific properties.

Application

Properties provided by the client sending the message.