@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; }
/** * Transform an ActiveMQBytesMessage to a Map * * @param msg - bytes message to transform * @return map object * @throws JMSException */ protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException { Properties props = new Properties(); props.putAll(transformToMap((ActiveMQMessage)msg)); long bodyLength = msg.getBodyLength(); byte[] msgBody; int i = 0; // Create separate bytes messages for (i = 0; i < (bodyLength / Integer.MAX_VALUE); i++) { msgBody = new byte[Integer.MAX_VALUE]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); } msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); return props; }
/** * Transform an ActiveMQBytesMessage to a Map * * @param msg - bytes message to transform * @return map object * @throws JMSException */ protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException { Properties props = new Properties(); props.putAll(transformToMap((ActiveMQMessage)msg)); long bodyLength = msg.getBodyLength(); byte[] msgBody; int i = 0; // Create separate bytes messages for (i = 0; i < (bodyLength / Integer.MAX_VALUE); i++) { msgBody = new byte[Integer.MAX_VALUE]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); } msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); return props; }
/** * Transform an ActiveMQBytesMessage to a Map * * @param msg - bytes message to transform * @return map object * @throws JMSException */ protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException { Properties props = new Properties(); props.putAll(transformToMap((ActiveMQMessage)msg)); long bodyLength = msg.getBodyLength(); byte[] msgBody; int i = 0; // Create separate bytes messages for (i = 0; i < (bodyLength / Integer.MAX_VALUE); i++) { msgBody = new byte[Integer.MAX_VALUE]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); } msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)]; props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i + 1), new String(msgBody)); return props; }
@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; }
buffer = new byte[(int)bm.getBodyLength()]; bm.readBytes(buffer); pos = 0;
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; }
byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data);
byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data);
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; }
ActiveMQBytesMessage msg = (ActiveMQBytesMessage) message.copy(); msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data));
ActiveMQBytesMessage msg = (ActiveMQBytesMessage) message.copy(); msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data));
ActiveMQBytesMessage msg = (ActiveMQBytesMessage) message.copy(); msg.setReadOnlyBody(true); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data));