/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final ICoreMessage message) throws Exception { SimpleString sstring = message.getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Base64 encode a ServerMessage body into the proper XML format */ static String encodeMessageBodyBase64(final Message message) throws Exception { Preconditions.checkNotNull(message, "ServerMessage can not be null"); ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer(); byte[] buffer = new byte[byteBuffer.writerIndex()]; byteBuffer.readBytes(buffer); return XmlDataExporterUtil.encode(buffer); }
/** * Base64 encode a ServerMessage body into the proper XML format */ static String encodeMessageBodyBase64(final Message message) throws Exception { Preconditions.checkNotNull(message, "ServerMessage can not be null"); ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer(); byte[] buffer = new byte[byteBuffer.writerIndex()]; byteBuffer.readBytes(buffer); return XmlDataExporterUtil.encode(buffer); }
public void printMessageBody(Message message, boolean encodeTextMessageUTF8) throws Exception { xmlWriter.writeStartElement(XmlDataConstants.MESSAGE_BODY); if (message.isLargeMessage()) { printLargeMessageBody((LargeServerMessage) message); } else { if (encodeTextMessageUTF8 && message.toCore().getType() == Message.TEXT_TYPE) { xmlWriter.writeCData(TextMessageUtil.readBodyText(message.toCore().getReadOnlyBodyBuffer()).toString()); } else { xmlWriter.writeCData(XmlDataExporterUtil.encodeMessageBodyBase64(message)); } } xmlWriter.writeEndElement(); // end MESSAGE_BODY }
@Override public Map<String, Object> getFields(MessageReference ref) throws OpenDataException { Map<String, Object> rc = super.getFields(ref); ICoreMessage m = ref.getMessage().toCore(); if (!m.isLargeMessage()) { SimpleString text = m.getReadOnlyBodyBuffer().readNullableSimpleString(); rc.put(CompositeDataConstants.TEXT_BODY, text != null ? text.toString() : ""); } else { rc.put(CompositeDataConstants.TEXT_BODY, ""); } return rc; } }
public void printMessageBody(Message message, boolean encodeTextMessageUTF8) throws Exception { xmlWriter.writeStartElement(XmlDataConstants.MESSAGE_BODY); if (message.isLargeMessage()) { printLargeMessageBody((LargeServerMessage) message); } else { if (encodeTextMessageUTF8 && message.toCore().getType() == Message.TEXT_TYPE) { xmlWriter.writeCData(TextMessageUtil.readBodyText(message.toCore().getReadOnlyBodyBuffer()).toString()); } else { xmlWriter.writeCData(XmlDataExporterUtil.encodeMessageBodyBase64(message)); } } xmlWriter.writeEndElement(); // end MESSAGE_BODY }
@Override public Map<String, Object> getFields(MessageReference ref) throws OpenDataException { Map<String, Object> rc = super.getFields(ref); ICoreMessage m = ref.getMessage().toCore(); if (!m.isLargeMessage()) { ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer(); byte[] bytes = new byte[bodyCopy.readableBytes()]; bodyCopy.readBytes(bytes); rc.put(CompositeDataConstants.BODY, bytes); } else { rc.put(CompositeDataConstants.BODY, new byte[0]); } return rc; } }
public static Message extractEmbedded(ICoreMessage message) { if (message.getType() == Message.EMBEDDED_TYPE) { ActiveMQBuffer buffer = message.getReadOnlyBodyBuffer(); if (buffer.readableBytes() < signature.length || !checkSignature(buffer)) { logger.tracef("Message type %d was used for something other than embed messages, ignoring content and treating as a regular message", Message.EMBEDDED_TYPE); return message; } try { return MessagePersister.getInstance().decode(buffer, null); } catch (Exception e) { logger.warn(e.getMessage(), e); return message; } } else { return message; } }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final ICoreMessage message) throws Exception { SimpleString sstring = message.getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final ICoreMessage message) throws Exception { SimpleString sstring = message.getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final ICoreMessage message) throws Exception { SimpleString sstring = message.getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final ICoreMessage message) throws Exception { SimpleString sstring = message.getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
/** * Used by ActiveMQ Artemis management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.toCore().getReadOnlyBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JsonArray jsonArray = JsonUtil.readJsonArray(jsonString); return JsonUtil.fromJsonArray(jsonArray); } else { return null; } }
private static Message asLargeMessage(Message message, StorageManager storageManager) throws Exception { ICoreMessage coreMessage = message.toCore(); LargeServerMessage lsm = storageManager.createLargeMessage(storageManager.generateID(), coreMessage); ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer(); final int readableBytes = buffer.readableBytes(); lsm.addBytes(buffer); lsm.releaseResources(); lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, readableBytes); return lsm; }