To create a message, you must first create an instance of a Session object. See “Creating sessions” for details. The following sample code creates a JMS text messages using the session called mySession:
javax.jms.TextMessage myTextMsg = mySession.createTextMessage(“Text message”);
EAServer supports six message types that a message producer can send or publish. Table 3-1 describes the message types and the javax.jms.Session interface APIs used to create instances of each.
Message type |
Create message API |
Comments |
---|---|---|
Plain |
Session.createMessage |
Creates a message without a message body. |
Text |
Session.createTextMessage |
Creates a message that can contain a string in the message body. |
Object |
Session.createObjectMessage |
Creates a message that can contain a serializable Java object in the message body. |
Stream |
Session.createStreamMessage |
Creates a message that can contain a stream of Java primitives in the message body. Fill and read the message sequentially. |
Map |
Session.createMapMessage |
Creates a message whose body can contain a set of name-value pairs where names are Strings and values are Java primitive types. |
Bytes |
Session.createBytesMessage |
Creates a message that can contain a stream of uninterpreted bytes in the message body. |
To improve interoperability with non-Java clients or components and to improve message receivers’ ability to filter messages, Sybase recommends that you use either plain messages or text messages.
Message selectors allow you to filter messages based on text in the message properties. You cannot filter messages based on text in the message body.
For more information about message types and message properties, see the JMS 1.1 API documentation.