Example usage for javax.jms BytesMessage setJMSType

List of usage examples for javax.jms BytesMessage setJMSType

Introduction

In this page you can find the example usage for javax.jms BytesMessage setJMSType.

Prototype


void setJMSType(String type) throws JMSException;

Source Link

Document

Sets the message type.

Usage

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

private void createByteMsgs(int numMessages) throws Exception {
    BytesMessage message = testMeta.session.createBytesMessage();
    for (int i = 0; i < numMessages; i++) {
        message.writeBytes(("Message: " + i).getBytes());
        message.setIntProperty("counter", i);
        message.setJMSCorrelationID("MyCorrelationID");
        message.setJMSReplyTo(new ActiveMQQueue("MyReplyTo"));
        message.setJMSType("MyType");
        message.setJMSPriority(5);/*from  ww w.j a v a 2 s . c o  m*/
        testMeta.producer.send(message);
    }
}

From source file:org.bremersee.common.jms.DefaultJmsConverter.java

private Message createSerializedMessage(Serializable object, Session session) throws JMSException {
    try {//from   www. ja v a2s.  c  o m
        BytesMessage msg = session.createBytesMessage();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        objectOutputStream.writeObject(object);
        objectOutputStream.flush();
        msg.writeBytes(outputStream.toByteArray());
        msg.setJMSType(object.getClass().getName());
        return msg;

    } catch (Throwable t) { // NOSONAR
        log.info("Creating Serialized JMS from object of type ["
                + (object == null ? "null" : object.getClass().getName()) + "] failed.");
        return null;
    }
}