O'Reilly logo

Java Message Service by Richard Monson-Haefel, David A Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Properties

Properties act like additional headers that can be assigned to a message. They provide the developer with more information about the message. The Message interface provides several accessor and mutator methods for reading and writing properties. The value of a property can be a String, boolean, byte, double, int, long, or float.

There are three basic categories of message properties: application-specific properties, JMS-defined properties, and provider-specific properties. Application properties are defined and applied to Message objects by the application developer; the JMS extension and provider-specific properties are additional headers that are, for the most part, automatically added by the JMS provider.

Application-Specific Properties

Any property defined by the application developer can be an application-specific property. Application properties are set before the message is delivered. There are no predefined application properties; developers are free to define any properties that fit their needs. For example, in the chat example developed in Chapter 2, a special property could be added that identifies the user sending the message:

TextMessage message = pubSession.createTextMessage(  );
message.setText(text);
message.setStringProperty("username",username);
publisher.publish(message);

As an application specific-property, username is not meaningful outside the Chat application; it is used exclusively by the application to filter messages based on the identity of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required