Java Code Examples for javax.jms.StreamMessage#reset()

The following examples show how to use javax.jms.StreamMessage#reset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException {
   super.assertEquivalent(m, mode, redelivery);

   StreamMessage sm = (StreamMessage) m;

   sm.reset();

   ProxyAssertSupport.assertEquals(true, sm.readBoolean());
   ProxyAssertSupport.assertEquals((byte) 3, sm.readByte());
   byte[] bytes = new byte[3];
   sm.readBytes(bytes);
   ProxyAssertSupport.assertEquals((byte) 4, bytes[0]);
   ProxyAssertSupport.assertEquals((byte) 5, bytes[1]);
   ProxyAssertSupport.assertEquals((byte) 6, bytes[2]);
   ProxyAssertSupport.assertEquals(-1, sm.readBytes(bytes));
   ProxyAssertSupport.assertEquals((char) 7, sm.readChar());
   ProxyAssertSupport.assertEquals(new Double(8.0), new Double(sm.readDouble()));
   ProxyAssertSupport.assertEquals(new Float(9.0), new Float(sm.readFloat()));
   ProxyAssertSupport.assertEquals(10, sm.readInt());
   ProxyAssertSupport.assertEquals(11L, sm.readLong());
   ProxyAssertSupport.assertEquals("this is an object", sm.readObject());
   ProxyAssertSupport.assertEquals((short) 12, sm.readShort());
   ProxyAssertSupport.assertEquals("this is a String", sm.readString());
}
 
Example 2
Source File: ActiveMQStreamMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public ActiveMQStreamMessage(final StreamMessage foreign, final ClientSession session) throws JMSException {
   super(foreign, ActiveMQStreamMessage.TYPE, session);

   foreign.reset();

   try {
      while (true) {
         Object obj = foreign.readObject();
         writeObject(obj);
      }
   } catch (MessageEOFException e) {
      // Ignore
   }
}