Show TOC

Procedure documentationProcessing Messages Locate this document in the navigation structure

 

There are several message types defined by the JMS specification that the applications can create and receive, all implementing the javax.jms.Message interface.

  • Generic Message - consists only of a message header and properties.

  • Byte Message - represents an array of bytes.

  • Map Message - contains a set of name-value pairs.

  • Object Message - has a payload that is a Serializable Java object.

  • Stream Message - contains a stream of Java primitive values.

  • Text Message - contains java.lang.String object.

Procedure

Processing Byte Message

Syntax Syntax

  1. // create a byte array with the received data
    
    byte[] receivedBytes;
    
    // create an integer object to receive the data with that specified length:
    
    int dataLength;
    
    // get the data from the Bytes Message:
    
    dataLength = bytesMessage.readBytes(receivedBytes);
    
End of the code.
Processing Map Message

Syntax Syntax

  1. String stringData;
    
    long longData;
    
    stringData = mapMessage.getString(“message”);
    
    longData = mapMessage.getLong(“long”);
    
End of the code.
Processing Objects Message

Syntax Syntax

  1. String stringValue;
    
    long longValue;
    
    Class_Implementing_Serialaizable cis = new Class_Implementing_Serialaizable();
    
    cis =  objectMessage.getObject();
    
    stringValue = cis.getString();
    
    longValue = cis.getLong();
    
    
End of the code.
Processing Stream Message

Syntax Syntax

  1. String stringValue;
    
    long longValue;
    
    stringValue = streamMessage.readString();
    
    longValue = streamMessage.readLong();
    
End of the code.
Processing Text Message

Syntax Syntax

  1. String text;
    
    text = textMessage.getText();
    
End of the code.