Java Code Examples for javax.jms.StreamMessage#readBytes()
The following examples show how to use
javax.jms.StreamMessage#readBytes() .
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: JmsFactory.java From localization_nifi with Apache License 2.0 | 6 votes |
private static byte[] getMessageBytes(StreamMessage message) throws JMSException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] byteBuffer = new byte[4096]; int byteCount; while ((byteCount = message.readBytes(byteBuffer)) != -1) { baos.write(byteBuffer, 0, byteCount); } try { baos.close(); } catch (final IOException ioe) { } return baos.toByteArray(); }
Example 2
Source File: ForeignStreamMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException { super.assertEquivalent(m, mode, redelivery); StreamMessage sm = (StreamMessage) m; ProxyAssertSupport.assertTrue(sm.readBoolean()); byte[] bytes = new byte[5]; sm.readBytes(bytes); String s = new String(bytes); ProxyAssertSupport.assertEquals("jboss", s); ProxyAssertSupport.assertEquals(-1, sm.readBytes(bytes)); ProxyAssertSupport.assertEquals(sm.readChar(), 'c'); ProxyAssertSupport.assertEquals(sm.readDouble(), 1.0D, 0.0D); ProxyAssertSupport.assertEquals(sm.readFloat(), 2.0F, 0.0F); ProxyAssertSupport.assertEquals(sm.readInt(), 3); ProxyAssertSupport.assertEquals(sm.readLong(), 4L); ProxyAssertSupport.assertEquals(sm.readObject(), "object"); ProxyAssertSupport.assertEquals(sm.readShort(), (short) 5); ProxyAssertSupport.assertEquals(sm.readString(), "stringvalue"); }
Example 3
Source File: StreamMessageTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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 4
Source File: JmsFactory.java From nifi with Apache License 2.0 | 6 votes |
private static byte[] getMessageBytes(StreamMessage message) throws JMSException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] byteBuffer = new byte[4096]; int byteCount; while ((byteCount = message.readBytes(byteBuffer)) != -1) { baos.write(byteBuffer, 0, byteCount); } try { baos.close(); } catch (final IOException ioe) { } return baos.toByteArray(); }
Example 5
Source File: FatalJmsExceptionMessageCreator.java From jadira with Apache License 2.0 | 6 votes |
private static byte[] extractByteArrayFromMessage(StreamMessage message) throws JMSException { ByteArrayOutputStream oStream = new ByteArrayOutputStream(BUFFER_CAPACITY_BYTES); byte[] buffer = new byte[BUFFER_CAPACITY_BYTES]; int bufferCount = -1; while ((bufferCount = message.readBytes(buffer)) >= 0) { oStream.write(buffer, 0, bufferCount); if (bufferCount < BUFFER_CAPACITY_BYTES) { break; } } return oStream.toByteArray(); }
Example 6
Source File: CompressedInteropTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void receiveStreamMessage(boolean useCore) throws Exception { StreamMessage streamMessage = (StreamMessage) receiveMessage(useCore); boolean booleanVal = streamMessage.readBoolean(); assertTrue(booleanVal); byte byteVal = streamMessage.readByte(); assertEquals((byte) 10, byteVal); byte[] originVal = TEXT.getBytes(); byte[] bytesVal = new byte[originVal.length]; streamMessage.readBytes(bytesVal); for (int i = 0; i < bytesVal.length; i++) { assertTrue(bytesVal[i] == originVal[i]); } char charVal = streamMessage.readChar(); assertEquals('A', charVal); double doubleVal = streamMessage.readDouble(); assertEquals(55.3D, doubleVal, 0.1D); float floatVal = streamMessage.readFloat(); assertEquals(79.1F, floatVal, 0.1F); int intVal = streamMessage.readInt(); assertEquals(37, intVal); long longVal = streamMessage.readLong(); assertEquals(56652L, longVal); Object objectVal = streamMessage.readObject(); Object origVal = new String("VVVV"); assertTrue(objectVal.equals(origVal)); short shortVal = streamMessage.readShort(); assertEquals((short) 333, shortVal); String strVal = streamMessage.readString(); assertEquals(TEXT, strVal); }