Example usage for javax.jms StreamMessage writeObject

List of usage examples for javax.jms StreamMessage writeObject

Introduction

In this page you can find the example usage for javax.jms StreamMessage writeObject.

Prototype


void writeObject(Object value) throws JMSException;

Source Link

Document

Writes an object to the stream message.

Usage

From source file:com.datatorrent.lib.io.jms.JMSObjectInputOperatorTest.java

private void createStreamMsgs(int numMessages) throws Exception {
    Long value = 1013L;//from  w  w  w.ja va2s . co m
    StreamMessage message = testMeta.session.createStreamMessage();
    message.writeObject(value);
    for (int i = 0; i < numMessages; i++) {
        testMeta.producer.send(message);
    }
}

From source file:org.mule.transport.jms.JmsMessageUtils.java

private static Message listToMessage(List<?> value, Session session) throws JMSException {
    StreamMessage sMsg = session.createStreamMessage();

    for (Iterator<?> iter = value.iterator(); iter.hasNext();) {
        Object o = iter.next();/* w ww.  ja v  a  2 s.c o m*/
        if (validateStreamMessageType(o)) {
            sMsg.writeObject(o);
        } else {
            throw new MessageFormatException(
                    String.format("Invalid type passed to StreamMessage: %s . Allowed types are: "
                            + "Boolean, Byte, Short, Character, Integer, Long, Float, Double,"
                            + "String and byte[]", ClassUtils.getShortClassName(o, "null")));
        }
    }
    return sMsg;
}