/** * Reads a byte array from the bytes message stream. * <P> * If the length of array <code>value</code> is less than the number of * bytes remaining to be read from the stream, the array should be filled. A * subsequent call reads the next increment, and so on. * <P> * If the number of bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. The * return value of the total number of bytes read will be less than the * length of the array, indicating that there are no more bytes left to be * read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return the total number of bytes read into the buffer, or -1 if there is * no more data because the end of the stream has been reached * @throws JMSException if the JMS provider fails to read the message due to * some internal error. * @throws MessageNotReadableException if the message is in write-only mode. */ @Override public int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); }
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQBytesMessage m = (ActiveMQBytesMessage)o; m.setReadOnlyBody(true); Map<String, Object> rc = super.getFields(o); long length = 0; try { length = m.getBodyLength(); rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length)); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0)); } try { byte preview[] = new byte[(int)Math.min(length, 255)]; m.readBytes(preview); m.reset(); // This is whack! Java 1.5 JMX spec does not support primitive // arrays! // In 1.6 it seems it is supported.. but until then... Byte data[] = new Byte[preview.length]; for (int i = 0; i < data.length; i++) { data[i] = new Byte(preview[i]); } rc.put(CompositeDataConstants.BODY_PREVIEW, data); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_PREVIEW, new Byte[] {}); } return rc; }
/** * Reads a byte array from the bytes message stream. * <P> * If the length of array <code>value</code> is less than the number of * bytes remaining to be read from the stream, the array should be filled. A * subsequent call reads the next increment, and so on. * <P> * If the number of bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. The * return value of the total number of bytes read will be less than the * length of the array, indicating that there are no more bytes left to be * read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return the total number of bytes read into the buffer, or -1 if there is * no more data because the end of the stream has been reached * @throws JMSException if the JMS provider fails to read the message due to * some internal error. * @throws MessageNotReadableException if the message is in write-only mode. */ @Override public int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); }
/** * Reads a byte array from the bytes message stream. * <P> * If the length of array <code>value</code> is less than the number of * bytes remaining to be read from the stream, the array should be filled. A * subsequent call reads the next increment, and so on. * <P> * If the number of bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. The * return value of the total number of bytes read will be less than the * length of the array, indicating that there are no more bytes left to be * read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return the total number of bytes read into the buffer, or -1 if there is * no more data because the end of the stream has been reached * @throws JMSException if the JMS provider fails to read the message due to * some internal error. * @throws MessageNotReadableException if the message is in write-only mode. */ @Override public int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); }
/** * Reads a byte array from the bytes message stream. * <P> * If the length of array <code>value</code> is less than the number of * bytes remaining to be read from the stream, the array should be filled. A * subsequent call reads the next increment, and so on. * <P> * If the number of bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. The * return value of the total number of bytes read will be less than the * length of the array, indicating that there are no more bytes left to be * read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return the total number of bytes read into the buffer, or -1 if there is * no more data because the end of the stream has been reached * @throws JMSException if the JMS provider fails to read the message due to * some internal error. * @throws MessageNotReadableException if the message is in write-only mode. */ @Override public int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); }
/** * Reads a byte array from the bytes message stream. * <P> * If the length of array <code>value</code> is less than the number of * bytes remaining to be read from the stream, the array should be filled. A * subsequent call reads the next increment, and so on. * <P> * If the number of bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. The * return value of the total number of bytes read will be less than the * length of the array, indicating that there are no more bytes left to be * read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return the total number of bytes read into the buffer, or -1 if there is * no more data because the end of the stream has been reached * @throws JMSException if the JMS provider fails to read the message due to * some internal error. * @throws MessageNotReadableException if the message is in write-only mode. */ public int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); }
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQBytesMessage m = (ActiveMQBytesMessage)o; m.setReadOnlyBody(true); Map<String, Object> rc = super.getFields(o); long length = 0; try { length = m.getBodyLength(); rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length)); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0)); } try { byte preview[] = new byte[(int)Math.min(length, 255)]; m.readBytes(preview); // This is whack! Java 1.5 JMX spec does not support primitive // arrays! // In 1.6 it seems it is supported.. but until then... Byte data[] = new Byte[preview.length]; for (int i = 0; i < data.length; i++) { data[i] = new Byte(preview[i]); } rc.put(CompositeDataConstants.BODY_PREVIEW, data); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_PREVIEW, new Byte[] {}); } return rc; }
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQBytesMessage m = (ActiveMQBytesMessage)o; m.setReadOnlyBody(true); Map<String, Object> rc = super.getFields(o); long length = 0; try { length = m.getBodyLength(); rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length)); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0)); } try { byte preview[] = new byte[(int)Math.min(length, 255)]; m.readBytes(preview); m.reset(); // This is whack! Java 1.5 JMX spec does not support primitive // arrays! // In 1.6 it seems it is supported.. but until then... Byte data[] = new Byte[preview.length]; for (int i = 0; i < data.length; i++) { data[i] = new Byte(preview[i]); } rc.put(CompositeDataConstants.BODY_PREVIEW, data); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_PREVIEW, new Byte[] {}); } return rc; }
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQBytesMessage m = (ActiveMQBytesMessage)o; m.setReadOnlyBody(true); Map<String, Object> rc = super.getFields(o); long length = 0; try { length = m.getBodyLength(); rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length)); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0)); } try { byte preview[] = new byte[(int)Math.min(length, 255)]; m.readBytes(preview); m.reset(); // This is whack! Java 1.5 JMX spec does not support primitive // arrays! // In 1.6 it seems it is supported.. but until then... Byte data[] = new Byte[preview.length]; for (int i = 0; i < data.length; i++) { data[i] = new Byte(preview[i]); } rc.put(CompositeDataConstants.BODY_PREVIEW, data); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_PREVIEW, new Byte[] {}); } return rc; }
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQBytesMessage m = (ActiveMQBytesMessage)o; m.setReadOnlyBody(true); Map<String, Object> rc = super.getFields(o); long length = 0; try { length = m.getBodyLength(); rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length)); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0)); } try { byte preview[] = new byte[(int)Math.min(length, 255)]; m.readBytes(preview); m.reset(); // This is whack! Java 1.5 JMX spec does not support primitive // arrays! // In 1.6 it seems it is supported.. but until then... Byte data[] = new Byte[preview.length]; for (int i = 0; i < data.length; i++) { data[i] = new Byte(preview[i]); } rc.put(CompositeDataConstants.BODY_PREVIEW, data); } catch (JMSException e) { rc.put(CompositeDataConstants.BODY_PREVIEW, new Byte[] {}); } return rc; }
bm.readBytes(buffer); pos = 0; if (jmsProperties == null) {
public StompFrame convertMessage(ProtocolConverter converter, ActiveMQMessage message) throws IOException, JMSException { StompFrame command = new StompFrame(); command.setAction(Stomp.Responses.MESSAGE); Map<String, String> headers = new HashMap<String, String>(25); command.setHeaders(headers); FrameTranslator.Helper.copyStandardHeadersFromMessageToFrame(converter, message, command, this); if (message.getDataStructureType() == ActiveMQTextMessage.DATA_STRUCTURE_TYPE) { ActiveMQTextMessage msg = (ActiveMQTextMessage)message.copy(); command.setContent(msg.getText().getBytes("UTF-8")); } else if (message.getDataStructureType() == ActiveMQBytesMessage.DATA_STRUCTURE_TYPE) { ActiveMQBytesMessage msg = (ActiveMQBytesMessage)message.copy(); msg.setReadOnlyBody(true); byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data); headers.put(Stomp.Headers.CONTENT_LENGTH, "" + data.length); command.setContent(data); } else if (message.getDataStructureType() == ActiveMQMessage.DATA_STRUCTURE_TYPE && AdvisorySupport.ADIVSORY_MESSAGE_TYPE.equals(message.getType())) { FrameTranslator.Helper.copyStandardHeadersFromMessageToFrame( converter, message, command, this); String body = marshallAdvisory(message.getDataStructure()); command.setContent(body.getBytes("UTF-8")); } return command; }
msg.setReadOnlyBody(true); byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
msg.setReadOnlyBody(true); byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data);
msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data);
msg.setReadOnlyBody(true); byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
/** * Return the encoded form of the BytesMessage as an AMQP Binary instance. * * @param message * the Message whose binary encoded body is needed. * * @return a Binary instance containing the encoded message body. * * @throws JMSException if an error occurs while fetching the binary payload. */ public static Binary getBinaryFromMessageBody(ActiveMQBytesMessage message) throws JMSException { Binary result = null; if (message.getContent() != null) { ByteSequence contents = message.getContent(); if (message.isCompressed()) { int length = (int) message.getBodyLength(); byte[] uncompressed = new byte[length]; message.readBytes(uncompressed); result = new Binary(uncompressed); } else { return new Binary(contents.getData(), contents.getOffset(), contents.getLength()); } } return result; }
/** * Return the encoded form of the BytesMessage as an AMQP Binary instance. * * @param message * the Message whose binary encoded body is needed. * * @return a Binary instance containing the encoded message body. * * @throws JMSException if an error occurs while fetching the binary payload. */ public static Binary getBinaryFromMessageBody(ActiveMQBytesMessage message) throws JMSException { Binary result = null; if (message.getContent() != null) { ByteSequence contents = message.getContent(); if (message.isCompressed()) { int length = (int) message.getBodyLength(); byte[] uncompressed = new byte[length]; message.readBytes(uncompressed); result = new Binary(uncompressed); } else { return new Binary(contents.getData(), contents.getOffset(), contents.getLength()); } } return result; }
msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data)); } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) {